From 44c304cefb6e9f53c16eec278999ac19f2572a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 12 Sep 2017 12:58:45 +0200 Subject: 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 --- src/gui/kernel/qwindow.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/gui/kernel/qwindow.cpp') 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(); -- cgit v1.2.3