Commit f75d55f1a71cae9864ca4bf12c92fcd9e34ed651

Revert "Prevent widgets with WA_DontShowOnScreen from keeping the app running"

This reverts commit 424eabac69df3234006669a69ca0ec9653e4ce63.

The commit changed behavior of WA_QuitOnClose when WA_DontShowOnScreen
was used, but WA_DontShowOnScreen should only have visual effects.

Reviewed-by: Bjørn Erik Nilsen <bjorn.nilsen@nokia.com>
  
75737573 if (isMain)
75747574 QApplication::quit();
75757575#endif
7576 // Attempt to close the application only if this widget has the
7577 // WA_QuitOnClose flag set set and has a non-visible parent
7578 quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible() || parentWidget->testAttribute(Qt::WA_DontShowOnScreen));
7576 // Attempt to close the application only if this has WA_QuitOnClose set and a non-visible parent
7577 quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible());
75797578
75807579 if (quitOnClose) {
7581 // If there is no non-withdrawn primary window left (except
7582 // the ones without QuitOnClose or with WA_DontShowOnScreen),
7583 // we emit the lastWindowClosed signal
7580 /* if there is no non-withdrawn primary window left (except
7581 the ones without QuitOnClose), we emit the lastWindowClosed
7582 signal */
75847583 QWidgetList list = QApplication::topLevelWidgets();
75857584 bool lastWindowClosed = true;
75867585 for (int i = 0; i < list.size(); ++i) {
75877586 QWidget *w = list.at(i);
7588 if ((w->isVisible() && !w->testAttribute(Qt::WA_DontShowOnScreen))
7589 && !w->parentWidget() && w->testAttribute(Qt::WA_QuitOnClose)) {
7590 lastWindowClosed = false;
7591 break;
7592 }
7587 if (!w->isVisible() || w->parentWidget() || !w->testAttribute(Qt::WA_QuitOnClose))
7588 continue;
7589 lastWindowClosed = false;
7590 break;
75937591 }
75947592 if (lastWindowClosed)
75957593 QApplicationPrivate::emitLastWindowClosed();
  
706706 QSignalSpy spy(&app, SIGNAL(aboutToQuit()));
707707 QSignalSpy spy2(&timer, SIGNAL(timeout()));
708708
709 QPointer<QMainWindow> mainWindow = new QMainWindow;
710 QPointer<QWidget> invisibleTopLevelWidget = new QWidget;
711 invisibleTopLevelWidget->setAttribute(Qt::WA_DontShowOnScreen);
712
713 QVERIFY(app.quitOnLastWindowClosed());
714 QVERIFY(mainWindow->testAttribute(Qt::WA_QuitOnClose));
715 QVERIFY(invisibleTopLevelWidget->testAttribute(Qt::WA_QuitOnClose));
716 QVERIFY(invisibleTopLevelWidget->testAttribute(Qt::WA_DontShowOnScreen));
717
718 mainWindow->show();
719 invisibleTopLevelWidget->show();
720
721 timer.start();
722 QTimer::singleShot(1000, mainWindow, SLOT(close())); // This should quit the application
723 QTimer::singleShot(2000, &app, SLOT(quit())); // This makes sure we quit even if it didn't
724
725 app.exec();
726
727 QCOMPARE(spy.count(), 1);
728 QVERIFY(spy2.count() < 15); // Should be around 10 if closing caused the quit
729 }
730 {
731 int argc = 0;
732 QApplication app(argc, 0, QApplication::GuiServer);
733 QTimer timer;
734 timer.setInterval(100);
735
736 QSignalSpy spy(&app, SIGNAL(aboutToQuit()));
737 QSignalSpy spy2(&timer, SIGNAL(timeout()));
738
739709 QPointer<CloseEventTestWindow> mainWindow = new CloseEventTestWindow;
740710
741711 QVERIFY(app.quitOnLastWindowClosed());