summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidget.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-09-03 15:06:59 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-09-17 14:56:19 +0200
commit28b14b966fe8535d7a81914b70759546b694e31b (patch)
tree707f4b0702242cf4a7e01e5003d9772e8bb1a703 /src/widgets/kernel/qwidget.cpp
parent1b0cb842129616d67ddf279e7e900fcdf433e390 (diff)
Deduplicate maybeQuitOnLastWindowClosed handling
The functionality now lives in QGuiApplication, and is triggered by QGuiApplication and QApplication after dispatching the close event to the window. The slight difference between how a Qt GUI and Qt Widget app determines if a window should contribute to the close-on-quit behavior has been abstracted into a QWindowPrivate helper. The additional checks that were in place for skipping out of the whole maybeQuitOnLastWindowClosed machinery have been kept. Task-number: QTBUG-53286 Change-Id: I81bd474755f9adb3a2b082621e5ecaa1c4726808 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r--src/widgets/kernel/qwidget.cpp26
1 files changed, 0 insertions, 26 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index dcd3d1f1d9a..a92454547aa 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -8399,8 +8399,6 @@ bool QWidgetPrivate::handleClose(CloseMode mode)
QPointer<QWidget> that = q;
QPointer<QWidget> parentWidget = (q->parentWidget() && !QObjectPrivate::get(q->parentWidget())->wasDeleted) ? q->parentWidget() : nullptr;
- bool quitOnClose = q->testAttribute(Qt::WA_QuitOnClose);
-
if (data.in_destructor)
mode = CloseNoEvent;
@@ -8420,30 +8418,6 @@ bool QWidgetPrivate::handleClose(CloseMode mode)
if (!that.isNull() && !q->isHidden())
q->hide();
- // 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), 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->parentWidget() || !w->testAttribute(Qt::WA_QuitOnClose))
- continue;
- lastWindowClosed = false;
- break;
- }
- if (lastWindowClosed) {
- QGuiApplicationPrivate::emitLastWindowClosed();
- QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance()));
- applicationPrivate->maybeQuit();
- }
- }
-
-
if (!that.isNull()) {
data.is_closing = false;
if (q->testAttribute(Qt::WA_DeleteOnClose)) {