summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-09-12 12:58:45 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-09-26 12:50:01 +0000
commit44c304cefb6e9f53c16eec278999ac19f2572a03 (patch)
tree88104e6eeb26001de0ee375bbc1a806698adf957
parent542e11ab2bd4a607fda8f559cc7efc32371b4e0e (diff)
Reset QWindowPrivate::platformWindow during destruction before deleting it
Otherwise the deletion of the platform window may result in platform events that then conclude the QWindow has a valid platform window and calls into it, when it's been half-way destroyed. Change-Id: If9eaad1b4e6aa414ba0f96475756a2146e0c01d5 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
-rw-r--r--src/gui/kernel/qwindow.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 5b5c1bd0e3..6dbba8b433 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -1882,11 +1882,16 @@ void QWindowPrivate::destroy()
QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed);
QGuiApplication::sendEvent(q, &e);
- delete platformWindow;
+ // Unset platformWindow before deleting, so that the destructor of the
+ // platform window does not recurse back into the platform window via
+ // this window during destruction (e.g. as a result of platform events).
+ QPlatformWindow *pw = platformWindow;
+ platformWindow = nullptr;
+ delete pw;
+
resizeEventPending = true;
receivedExpose = false;
exposed = false;
- platformWindow = 0;
if (wasVisible)
maybeQuitOnLastWindowClosed();