forked from qt-creator/qt-creator
Utils: Fix crash on showing tooltips when screen configuration changed
Check QGuiApplication::screenAt(QPoint) return value. TextTip will use QGuiApplication::primaryScreen() if it's nullptr. Fixes: QTCREATORBUG-25747 Change-Id: If02648966e24f96f8c9a92e91b2bd27c1efc5f9e Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -206,7 +206,12 @@ void TextTip::configure(const QPoint &pos)
|
||||
// Try to find a nice width without unnecessary wrapping.
|
||||
setWordWrap(false);
|
||||
int tipWidth = sizeHint().width();
|
||||
const int screenWidth = QGuiApplication::screenAt(pos)->availableGeometry().width();
|
||||
|
||||
QScreen *screen = QGuiApplication::screenAt(pos);
|
||||
if (!screen)
|
||||
screen = QGuiApplication::primaryScreen();
|
||||
|
||||
const int screenWidth = screen->availableGeometry().width();
|
||||
const int maxDesiredWidth = int(screenWidth * .5);
|
||||
if (tipWidth > maxDesiredWidth) {
|
||||
setWordWrap(true);
|
||||
|
Reference in New Issue
Block a user