summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwindow.cpp
diff options
context:
space:
mode:
authorJorgen Lind <jorgen.lind@digia.com>2014-07-08 13:24:24 +0200
committerJørgen Lind <jorgen.lind@digia.com>2014-07-10 15:39:38 +0200
commit0af228700e85167b9406193a38ea27584c6dc4d7 (patch)
tree08146a65817143159214dd3191428351e83351bb /src/gui/kernel/qwindow.cpp
parentc05fd55b96c8c3b765daedba7852bfbd5dc22943 (diff)
Make QWindow::close go through the QWindowSystemInterface
This causes a closeEvent to be sent for all calls to close. As a side effect destroy now handles more of the state in QGuiApplication. [ChangeLog][QtGui][QWindow] QWindow::close() sends a QCloseEvent which must be accepted before destroy() will be called. destroy() is the function to close the window without confirmation. Task-number: QTBUG-40093 Change-Id: I1ce09da4940fc29fae8decf40548a42e3bec6eca Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/gui/kernel/qwindow.cpp')
-rw-r--r--src/gui/kernel/qwindow.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 5630199da9..327544c59c 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -209,14 +209,8 @@ QWindow::QWindow(QWindowPrivate &dd, QWindow *parent)
*/
QWindow::~QWindow()
{
- if (QGuiApplicationPrivate::focus_window == this)
- QGuiApplicationPrivate::focus_window = 0;
- if (QGuiApplicationPrivate::currentMouseWindow == this)
- QGuiApplicationPrivate::currentMouseWindow = 0;
- if (QGuiApplicationPrivate::tabletPressTarget == this)
- QGuiApplicationPrivate::tabletPressTarget = 0;
- QGuiApplicationPrivate::window_list.removeAll(this);
destroy();
+ QGuiApplicationPrivate::window_list.removeAll(this);
}
void QWindowPrivate::init()
@@ -1569,16 +1563,28 @@ void QWindow::destroy()
QObject *object = childrenWindows.at(i);
if (object->isWindowType()) {
QWindow *w = static_cast<QWindow*>(object);
- QGuiApplicationPrivate::window_list.removeAll(w);
w->destroy();
}
}
+
+ if (QGuiApplicationPrivate::focus_window == this)
+ QGuiApplicationPrivate::focus_window = parent();
+ if (QGuiApplicationPrivate::currentMouseWindow == this)
+ QGuiApplicationPrivate::currentMouseWindow = parent();
+ if (QGuiApplicationPrivate::tabletPressTarget == this)
+ QGuiApplicationPrivate::tabletPressTarget = parent();
+
+ bool wasVisible = isVisible();
+
setVisible(false);
delete d->platformWindow;
d->resizeEventPending = true;
d->receivedExpose = false;
d->exposed = false;
d->platformWindow = 0;
+
+ if (wasVisible)
+ d->maybeQuitOnLastWindowClosed();
}
/*!
@@ -1839,15 +1845,10 @@ bool QWindow::close()
if (!d->platformWindow)
return true;
- if (QGuiApplicationPrivate::focus_window == this)
- QGuiApplicationPrivate::focus_window = 0;
- if (QGuiApplicationPrivate::currentMouseWindow == this)
- QGuiApplicationPrivate::currentMouseWindow = 0;
-
- QGuiApplicationPrivate::window_list.removeAll(this);
- destroy();
- d->maybeQuitOnLastWindowClosed();
- return true;
+ bool accepted = false;
+ QWindowSystemInterface::handleCloseEvent(this, &accepted);
+ QWindowSystemInterface::flushWindowSystemEvents();
+ return accepted;
}
/*!
@@ -1995,7 +1996,7 @@ bool QWindow::event(QEvent *ev)
case QEvent::Close:
if (ev->isAccepted())
- close();
+ destroy();
break;
case QEvent::Expose:
@@ -2208,8 +2209,10 @@ Q_GUI_EXPORT QWindowPrivate *qt_window_private(QWindow *window)
void QWindowPrivate::maybeQuitOnLastWindowClosed()
{
- Q_Q(QWindow);
+ if (!QCoreApplication::instance())
+ return;
+ Q_Q(QWindow);
// Attempt to close the application only if this has WA_QuitOnClose set and a non-visible parent
bool quitOnClose = QGuiApplication::quitOnLastWindowClosed() && !q->parent();