diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-01-09 13:17:52 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-01-09 14:14:53 +0100 |
commit | e0bb9e81ab1a9d71f2893844ea82430467422e21 (patch) | |
tree | f4e1b7fce0e815b04ebac237cc4123f9b8b8ea61 /tests/auto/widgets | |
parent | 349fda471e0df473f38f59c2baae688959d6d273 (diff) |
Don't override QDialog::setVisible() to implement native dialogs
Clients who called the base-class implementation in QDialog would
as a result start hitting the canBeNativeDialog code path at the
start of QDialog::setVisible(), which would show the native dialog,
but without updating the QWidget visibility state.
To keep things 100% compatible, we shuffle the implementation of
QDialog::setVisible() into QDialogPrivate, which allows us to
override it in QMessageBoxPrivate and QErrorMessagePrivate.
The existing subclasses of QDialog that override setVisible have
been left as is, to not cause any unintended behavior change.
Pick-to: 6.5
Change-Id: Icafe31a7b84a75049365e4e04b80492de08614d2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp | 9 | ||||
-rw-r--r-- | tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp | 10 |
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp b/tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp index 5cae8263dc..4a67e1c065 100644 --- a/tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp +++ b/tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp @@ -18,6 +18,7 @@ private slots: void dontShowAgain(); void dontShowCategoryAgain(); + void baseClassSetVisible(); }; @@ -138,5 +139,13 @@ void tst_QErrorMessage::dontShowCategoryAgain() QVERIFY(errorMessageDialog.isVisible()); } +void tst_QErrorMessage::baseClassSetVisible() +{ + QErrorMessage errorMessage; + errorMessage.QDialog::setVisible(true); + QCOMPARE(errorMessage.isVisible(), true); + errorMessage.close(); +} + QTEST_MAIN(tst_QErrorMessage) #include "tst_qerrormessage.moc" diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index 808cd41b28..122170e91d 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -27,6 +27,7 @@ private slots: void init(); void sanityTest(); + void baseClassSetVisible(); void defaultButton(); void escapeButton(); void clickedButton(); @@ -174,6 +175,15 @@ void tst_QMessageBox::sanityTest() msgBox.exec(); } +void tst_QMessageBox::baseClassSetVisible() +{ + QMessageBox msgBox; + msgBox.setText("Hello World"); + msgBox.QDialog::setVisible(true); + QCOMPARE(msgBox.isVisible(), true); + msgBox.close(); +} + void tst_QMessageBox::button() { QMessageBox msgBox; |