summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp')
-rw-r--r--tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
index b67f15458c..1363479897 100644
--- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
@@ -127,11 +127,20 @@ void ExecCloseHelper::timerEvent(QTimerEvent *te)
return;
QWidget *modalWidget = QApplication::activeModalWidget();
-
if (!m_testCandidate && modalWidget)
m_testCandidate = modalWidget;
- if (m_testCandidate && m_testCandidate == modalWidget) {
+ QWidget *activeWindow = QApplication::activeWindow();
+ if (!m_testCandidate && activeWindow)
+ m_testCandidate = activeWindow;
+
+ if (!m_testCandidate)
+ return;
+
+ bool shouldHelp = (m_testCandidate->isModal() && m_testCandidate == modalWidget)
+ || (!m_testCandidate->isModal() && m_testCandidate == activeWindow);
+
+ if (shouldHelp) {
if (m_key == CloseWindow) {
m_testCandidate->close();
} else {