summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-02-11 13:00:59 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-14 00:34:25 +0100
commit9835a63dde06a1e5d2f0452d50da86aa6790e4f7 (patch)
tree877a77c94daf2844c04e140376b0ef415cd35ae7 /src/gui
parentff11af4fbc2948a3a3bc635549c7ac349d249abc (diff)
Close widgets properly from session management.
Introduce new virtual QGuiApplicationPrivate::tryCloseAllWindows() which allows overriding the behavior in QApplication to properly close the widgets first. Without this, QGuiApplication closes the widget windows leaving a stale window handle behind in the associated QWidget which then causes the application not to terminate since QApplication::shouldQuit() stills finds the affected widgets to be visible. Task-number: QTBUG-35986 Change-Id: I19ac4b5a19250ee68d09e461c03dbace458c98e4 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qguiapplication.cpp40
-rw-r--r--src/gui/kernel/qguiapplication_p.h2
2 files changed, 25 insertions, 17 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 0f3f8d8ff2..3953437372 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -2696,6 +2696,27 @@ bool QGuiApplicationPrivate::shouldQuitInternal(const QWindowList &processedWind
return true;
}
+bool QGuiApplicationPrivate::tryCloseAllWindows()
+{
+ return tryCloseRemainingWindows(QWindowList());
+}
+
+bool QGuiApplicationPrivate::tryCloseRemainingWindows(QWindowList processedWindows)
+{
+ QWindowList list = QGuiApplication::topLevelWindows();
+ for (int i = 0; i < list.size(); ++i) {
+ QWindow *w = list.at(i);
+ if (w->isVisible() && !processedWindows.contains(w)) {
+ if (!w->close())
+ return false;
+ processedWindows.append(w);
+ list = QGuiApplication::topLevelWindows();
+ i = -1;
+ }
+ }
+ return true;
+}
+
/*!
\since 5.2
\fn Qt::ApplicationState QGuiApplication::applicationState()
@@ -2902,23 +2923,8 @@ void QGuiApplicationPrivate::commitData()
Q_Q(QGuiApplication);
is_saving_session = true;
emit q->commitDataRequest(*session_manager);
- if (session_manager->allowsInteraction()) {
- QWindowList done;
- QWindowList list = QGuiApplication::topLevelWindows();
- bool cancelled = false;
- for (int i = 0; !cancelled && i < list.size(); ++i) {
- QWindow* w = list.at(i);
- if (w->isVisible() && !done.contains(w)) {
- cancelled = !w->close();
- if (!cancelled)
- done.append(w);
- list = QGuiApplication::topLevelWindows();
- i = -1;
- }
- }
- if (cancelled)
- session_manager->cancel();
- }
+ if (session_manager->allowsInteraction() && !tryCloseAllWindows())
+ session_manager->cancel();
is_saving_session = false;
}
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index c23232182c..1ec808ec27 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -92,6 +92,7 @@ public:
virtual bool shouldQuit();
bool shouldQuitInternal(const QWindowList &processedWindows);
+ virtual bool tryCloseAllWindows();
static Qt::KeyboardModifiers modifier_buttons;
static Qt::MouseButtons mouse_buttons;
@@ -291,6 +292,7 @@ public:
protected:
virtual void notifyThemeChanged();
+ bool tryCloseRemainingWindows(QWindowList processedWindows);
#ifndef QT_NO_DRAGANDDROP
virtual void notifyDragStarted(const QDrag *);
#endif // QT_NO_DRAGANDDROP