summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorAndré de la Rocha <andre.rocha@qt.io>2022-04-22 20:41:55 +0200
committerAndré de la Rocha <andre.rocha@qt.io>2022-04-24 23:14:11 +0200
commit53c8d0d40bfc9a731a75f58f510c21b83b118d6d (patch)
treeb38dbb5bd214d029461e9b74e2389a0e4fb31914 /src/widgets
parentd42ad7b01e4d9b9fd097db5c438e7f646ef49b1b (diff)
Fix crash when calling QMainWindow::restoreState()
Restoring the state of a window with a dock widget could cause a crash in a multiple display configuration if the scale or screen arrangement in the system had changed after the state was saved. In this case, the original top-left coordinate of the window could now lie outside of any screens, which would result in a NULL QScreen pointer being dereferenced inside QDockAreaLayout::constrainedRect(). Fixes: QTBUG-102718 Fixes: QTBUG-102541 Pick-to: 6.2 6.3 Change-Id: Ie5e3209b82a33a1dc4568611c1b2ee3a6d8830b7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 1aca62c099..b374ed8134 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -3018,10 +3018,10 @@ QSize QDockAreaLayout::minimumStableSize() const
*/
QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget)
{
- QScreen *screen;
+ QScreen *screen = nullptr;
if (QGuiApplication::primaryScreen()->virtualSiblings().size() > 1)
screen = QGuiApplication::screenAt(rect.topLeft());
- else
+ if (!screen)
screen = widget->screen();
const QRect screenRect = screen->geometry();