diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index f61e15ddedd..df9ad57a18f 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -648,11 +648,11 @@ void QWindowsWindow::destroyWindow() { if (QWindowsContext::verboseIntegration || QWindowsContext::verboseWindows) qDebug() << __FUNCTION__ << this << window() << m_data.hwnd; - if (m_data.hwnd) { + if (m_data.hwnd) { // Stop event dispatching before Window is destroyed. unregisterDropSite(); + QWindowsContext::instance()->removeWindow(m_data.hwnd); if (m_data.hwnd != GetDesktopWindow()) DestroyWindow(m_data.hwnd); - QWindowsContext::instance()->removeWindow(m_data.hwnd); m_data.hwnd = 0; } }