ToolTip: Guard against nullptr access

screenAt(pos) can be nullptr if pos is outside the current screen
configuration. Seems to be possible when screen configurations change.

Fixes: QTCREATORBUG-26019
Change-Id: I5def200b14247e7fbcf62ad68cda991e8c10c9d7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Eike Ziller
2022-01-10 15:15:58 +01:00
parent 403ed474e2
commit b028af43ef

View File

@@ -156,7 +156,10 @@ void ToolTip::show(
if (content && content->count()) {
auto tooltipWidget = new FakeToolTip;
// limit the size of the widget to 90% of the screen size to have some context around it
tooltipWidget->setMaximumSize(QGuiApplication::screenAt(pos)->availableSize() * 0.9);
QScreen *qscreen = QGuiApplication::screenAt(pos);
if (!qscreen)
qscreen = QGuiApplication::primaryScreen();
tooltipWidget->setMaximumSize(qscreen->availableSize() * 0.9);
if (contextHelp.isNull()) {
tooltipWidget->setLayout(content);
} else {