diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-01-15 15:00:01 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-02-02 09:53:29 +0100 |
commit | ab1d5fddd3624faabcd20d3facf93054b398a010 (patch) | |
tree | 8768aae84a670b84ac1c31475e2e1f86fb779d02 /tests | |
parent | 82220c743a77d81c74935c8a9b36c13016968fb3 (diff) |
Windows: Fix dialog moving up after closing/reshowing
A resize event delivered after closing the platform window
was causing the stored frame margins to be cleared.
Bail out of QWidgetWindow::updateMargins() if the
platform window is null.
Pick-to: 5.15
Fixes: QTBUG-79147
Change-Id: Iebbc90c3cccafa209cd720baedf45affb3f3c2b8
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 7f5d41e286e043c5f3061e2eb5a0128102a38c80)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index 10a3746e36..3bdca59dd3 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -90,6 +90,7 @@ private slots: void transientParent_data(); void transientParent(); void dialogInGraphicsView(); + void keepPositionOnClose(); }; // Testing get/set functions @@ -677,5 +678,29 @@ void tst_QDialog::dialogInGraphicsView() } } +// QTBUG-79147 (Windows): Closing a dialog by clicking the 'X' in the title +// bar would offset the dialog position when shown next time. +void tst_QDialog::keepPositionOnClose() +{ +#ifdef Q_OS_WINRT + QSKIP("Does not work on winrt", Continue); +#endif + QDialog dialog; + dialog.setWindowTitle(QTest::currentTestFunction()); + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); + dialog.resize(availableGeometry.size() / 4); + const QPoint pos = availableGeometry.topLeft() + QPoint(100, 100); + dialog.move(pos); + dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + dialog.close(); + dialog.windowHandle()->destroy(); // Emulate a click on close by destroying the window. + QTest::qWait(50); + dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + QTest::qWait(50); + QCOMPARE(dialog.pos(), pos); +} + QTEST_MAIN(tst_QDialog) #include "tst_qdialog.moc" |