From 16c4224568b7969591120f163dc81ba61cd1e6f8 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 6 Feb 2012 16:58:15 +0200 Subject: Destroy the QWindow children in destroy() instead of close() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When closing a window, destroy() ensures a setVisible(false) call only for the window itself, not for other windows parented to it. With the new quit lock ref feature this breaks code that creates a fake root window parented to the main, visible window. (for example the xcomposite backends of qtwayland do this) Such apps do not anymore exit after closing their window because the children do not receive a deref due to setVisible not getting called. (At that point. It would get called after exiting the event loop but that never happens due to the refcounting) Change-Id: I124737c80ad59600ddc79261100f3904af0f410d Reviewed-by: Samuel Rødal --- src/gui/kernel/qwindow.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/gui/kernel/qwindow.cpp') diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 4436884359..b451a6ee33 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -731,6 +731,15 @@ void QWindow::setWindowIcon(const QImage &icon) const void QWindow::destroy() { Q_D(QWindow); + QObjectList childrenWindows = children(); + for (int i = 0; i < childrenWindows.size(); i++) { + QObject *object = childrenWindows.at(i); + if (object->isWindowType()) { + QWindow *w = static_cast(object); + QGuiApplicationPrivate::window_list.removeAll(w); + w->destroy(); + } + } setVisible(false); delete d->platformWindow; d->platformWindow = 0; @@ -881,16 +890,6 @@ bool QWindow::close() if (QGuiApplicationPrivate::focus_window == this) QGuiApplicationPrivate::focus_window = 0; - QObjectList childrenWindows = children(); - for (int i = 0; i < childrenWindows.size(); i++) { - QObject *object = childrenWindows.at(i); - if (object->isWindowType()) { - QWindow *w = static_cast(object); - QGuiApplicationPrivate::window_list.removeAll(w); - w->destroy(); - } - } - QGuiApplicationPrivate::window_list.removeAll(this); destroy(); d->maybeQuitOnLastWindowClosed(); -- cgit v1.2.3