summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qwidget.cpp20
-rw-r--r--tests/auto/qapplication/tst_qapplication.cpp30
2 files changed, 9 insertions, 41 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index e678220..884447d 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -7573,23 +7573,21 @@ bool QWidgetPrivate::close_helper(CloseMode mode)
if (isMain)
QApplication::quit();
#endif
- // Attempt to close the application only if this widget has the
- // WA_QuitOnClose flag set set and has a non-visible parent
- quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible() || parentWidget->testAttribute(Qt::WA_DontShowOnScreen));
+ // Attempt to close the application only if this has WA_QuitOnClose set and a non-visible parent
+ quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible());
if (quitOnClose) {
- // If there is no non-withdrawn primary window left (except
- // the ones without QuitOnClose or with WA_DontShowOnScreen),
- // we emit the lastWindowClosed signal
+ /* if there is no non-withdrawn primary window left (except
+ the ones without QuitOnClose), we emit the lastWindowClosed
+ signal */
QWidgetList list = QApplication::topLevelWidgets();
bool lastWindowClosed = true;
for (int i = 0; i < list.size(); ++i) {
QWidget *w = list.at(i);
- if ((w->isVisible() && !w->testAttribute(Qt::WA_DontShowOnScreen))
- && !w->parentWidget() && w->testAttribute(Qt::WA_QuitOnClose)) {
- lastWindowClosed = false;
- break;
- }
+ if (!w->isVisible() || w->parentWidget() || !w->testAttribute(Qt::WA_QuitOnClose))
+ continue;
+ lastWindowClosed = false;
+ break;
}
if (lastWindowClosed)
QApplicationPrivate::emitLastWindowClosed();
diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp
index b464867..459ac2b 100644
--- a/tests/auto/qapplication/tst_qapplication.cpp
+++ b/tests/auto/qapplication/tst_qapplication.cpp
@@ -706,36 +706,6 @@ void tst_QApplication::quitOnLastWindowClosed()
QSignalSpy spy(&app, SIGNAL(aboutToQuit()));
QSignalSpy spy2(&timer, SIGNAL(timeout()));
- QPointer<QMainWindow> mainWindow = new QMainWindow;
- QPointer<QWidget> invisibleTopLevelWidget = new QWidget;
- invisibleTopLevelWidget->setAttribute(Qt::WA_DontShowOnScreen);
-
- QVERIFY(app.quitOnLastWindowClosed());
- QVERIFY(mainWindow->testAttribute(Qt::WA_QuitOnClose));
- QVERIFY(invisibleTopLevelWidget->testAttribute(Qt::WA_QuitOnClose));
- QVERIFY(invisibleTopLevelWidget->testAttribute(Qt::WA_DontShowOnScreen));
-
- mainWindow->show();
- invisibleTopLevelWidget->show();
-
- timer.start();
- QTimer::singleShot(1000, mainWindow, SLOT(close())); // This should quit the application
- QTimer::singleShot(2000, &app, SLOT(quit())); // This makes sure we quit even if it didn't
-
- app.exec();
-
- QCOMPARE(spy.count(), 1);
- QVERIFY(spy2.count() < 15); // Should be around 10 if closing caused the quit
- }
- {
- int argc = 0;
- QApplication app(argc, 0, QApplication::GuiServer);
- QTimer timer;
- timer.setInterval(100);
-
- QSignalSpy spy(&app, SIGNAL(aboutToQuit()));
- QSignalSpy spy2(&timer, SIGNAL(timeout()));
-
QPointer<CloseEventTestWindow> mainWindow = new CloseEventTestWindow;
QVERIFY(app.quitOnLastWindowClosed());