diff options
author | Eike Ziller <eike.ziller@qt.io> | 2022-01-10 15:15:58 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2022-01-10 15:18:10 +0000 |
commit | b028af43efbb92ff6cc5413ffb11207481870116 (patch) | |
tree | 81790f79e7cd10d816c2a0d190e6131b44aa2ede | |
parent | 403ed474e2651e4b78d80973b5a143bc3fa9acc8 (diff) |
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>
-rw-r--r-- | src/libs/utils/tooltip/tooltip.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libs/utils/tooltip/tooltip.cpp b/src/libs/utils/tooltip/tooltip.cpp index 681524372d..60f10f5d71 100644 --- a/src/libs/utils/tooltip/tooltip.cpp +++ b/src/libs/utils/tooltip/tooltip.cpp @@ -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 { |