From 0de7440cc6ba0403588d1b5f8a6a557c7216334a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 8 Oct 2012 16:10:14 +0200 Subject: [PATCH] Windows: Filter out events sent during DestroyWindow(). Task-number: QTBUG-26933 Change-Id: Ie7aaf9f0c9c12a33b059e796a3be161a2d60c64e Reviewed-by: Miikka Heikkinen --- src/plugins/platforms/windows/qwindowscontext.cpp | 3 +++ src/plugins/platforms/windows/qwindowswindow.cpp | 3 ++- src/plugins/platforms/windows/qwindowswindow.h | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index bd69bf8b6a..0dade2c49b 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -776,6 +776,9 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, } } if (platformWindow) { + // Suppress events sent during DestroyWindow() for native children. + if (platformWindow->testFlag(QWindowsWindow::WithinDestroy)) + return false; if (QWindowsContext::verboseEvents > 1) qDebug().nospace() << "Event window: " << platformWindow->window(); } else { diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 955617e399..eb9b364cb7 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -737,10 +737,10 @@ void QWindowsWindow::destroyWindow() if (QWindowsContext::verboseIntegration || QWindowsContext::verboseWindows) qDebug() << __FUNCTION__ << this << window() << m_data.hwnd; if (m_data.hwnd) { // Stop event dispatching before Window is destroyed. + setFlag(WithinDestroy); if (hasMouseCapture()) setMouseGrabEnabled(false); unregisterDropSite(); - QWindowsContext::instance()->removeWindow(m_data.hwnd); #ifdef QT_OPENGL_ES_2 if (m_eglSurface) { if (QWindowsContext::verboseGL) @@ -760,6 +760,7 @@ void QWindowsWindow::destroyWindow() #endif if (m_data.hwnd != GetDesktopWindow()) DestroyWindow(m_data.hwnd); + QWindowsContext::instance()->removeWindow(m_data.hwnd); m_data.hwnd = 0; } } diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 3c9d415a8f..4b1792859f 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -126,7 +126,8 @@ public: SizeGripOperation = 0x100, FrameStrutEventsEnabled = 0x200, SynchronousGeometryChangeEvent = 0x400, - WithinSetStyle = 0x800 + WithinSetStyle = 0x800, + WithinDestroy = 0x1000 }; struct WindowData