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
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-04-25 02:38:56 +0000
commit8102ac4143b4ad227a06509508095e3d6917ef19 (patch)
treeed53b1a273830b9090d3535e329acbf35025c7d1 /src/widgets
parent99ad73ccb74b1f468396e49fcce36f8dae0dedc0 (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 Change-Id: Ie5e3209b82a33a1dc4568611c1b2ee3a6d8830b7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 53c8d0d40bfc9a731a75f58f510c21b83b118d6d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
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 626710cd54..69790e6f69 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -2994,10 +2994,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();