summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qmessagebox.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-09-21 15:51:16 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-09-23 16:19:13 +0200
commite9cef8e7fa1c1cf4956cd25ccc5504f2e7790e4e (patch)
tree283fca615a1ab994b1705abd339af2f0ae5c16d1 /src/widgets/dialogs/qmessagebox.cpp
parent7c26d7f482b9c15cc6ff850d5954151031010226 (diff)
QMessageBox: read geometry from the screen the message box belongs to
The current implementation found a QScreen by using the position of the mouse in a call to QGuiApplication::screenAt(). From the documentation, this function is allowed to return nullptr if the position is outside the screen. From the stack track in the bug report, it seems very likely that the mentioned call returns nullptr. This is strengthen by the fact that the crash happens for messageboxes that are maximized, so that you need to click on the upper corner of the screen to close it. And then only when HiDPI scaling is in use at the same time. This patch will change the code to just use the screen that the widget is on instead. If no screen can be resolved, the call will default to primary screen. Fixes: QTBUG-96639 Pick-to: 6.2 Change-Id: I31f0301318b358be9619caa31cc831b9598d5f90 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/dialogs/qmessagebox.cpp')
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index a3093f82c2..a6a4d588d3 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -363,7 +363,7 @@ void QMessageBoxPrivate::updateSize()
if (!q->isVisible())
return;
- const QSize screenSize = QGuiApplication::screenAt(QCursor::pos())->availableGeometry().size();
+ const QSize screenSize = q->screen()->availableGeometry().size();
int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this
// on small screens allows the messagebox be the same size as the screen
if (screenSize.width() <= 1024)