From b028af43efbb92ff6cc5413ffb11207481870116 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 10 Jan 2022 15:15:58 +0100 Subject: [PATCH] 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 Reviewed-by: --- src/libs/utils/tooltip/tooltip.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/tooltip/tooltip.cpp b/src/libs/utils/tooltip/tooltip.cpp index 681524372d1..60f10f5d71a 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 {