Windows: Filter out events sent during DestroyWindow().
authorFriedemann Kleint <Friedemann.Kleint@digia.com>
Mon, 8 Oct 2012 14:10:14 +0000 (16:10 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 10 Oct 2012 08:44:12 +0000 (10:44 +0200)
Task-number: QTBUG-26933

Change-Id: Ie7aaf9f0c9c12a33b059e796a3be161a2d60c64e
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
src/plugins/platforms/windows/qwindowscontext.cpp
src/plugins/platforms/windows/qwindowswindow.cpp
src/plugins/platforms/windows/qwindowswindow.h

index bd69bf8..0dade2c 100644 (file)
@@ -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 {
index 955617e..eb9b364 100644 (file)
@@ -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;
     }
 }
index 3c9d415..4b17928 100644 (file)
@@ -126,7 +126,8 @@ public:
         SizeGripOperation = 0x100,
         FrameStrutEventsEnabled = 0x200,
         SynchronousGeometryChangeEvent = 0x400,
-        WithinSetStyle = 0x800
+        WithinSetStyle = 0x800,
+        WithinDestroy = 0x1000
     };
 
     struct WindowData