Windows: Clear window under mouse in destruction of platform window.

Task-number: QTBUG-32042

Change-Id: I8aa5df84b7ca6deb47e0c3eff9a6a7d2c4793553
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
Friedemann Kleint 2013-07-29 12:25:48 +02:00 committed by The Qt Project
parent af96c6fed9
commit 88f4baf089
4 changed files with 11 additions and 1 deletions

View File

@ -582,6 +582,11 @@ QWindow *QWindowsContext::windowUnderMouse() const
return d->m_mouseHandler.windowUnderMouse();
}
void QWindowsContext::clearWindowUnderMouse()
{
d->m_mouseHandler.clearWindowUnderMouse();
}
/*!
\brief Find a child window at a screen point.

View File

@ -166,6 +166,7 @@ public:
unsigned cwex_flags) const;
QWindow *windowUnderMouse() const;
void clearWindowUnderMouse();
inline bool windowsProc(HWND hwnd, UINT message,
QtWindows::WindowsEventType et,

View File

@ -72,6 +72,7 @@ public:
static Qt::MouseButtons queryMouseButtons();
QWindow *windowUnderMouse() const { return m_windowUnderMouse.data(); }
void clearWindowUnderMouse() { m_windowUnderMouse = 0; }
private:
inline bool translateMouseWheelEvent(QWindow *window, HWND hwnd,

View File

@ -871,6 +871,9 @@ void QWindowsWindow::destroyWindow()
qDebug() << __FUNCTION__ << this << window() << m_data.hwnd;
if (m_data.hwnd) { // Stop event dispatching before Window is destroyed.
setFlag(WithinDestroy);
QWindowsContext *context = QWindowsContext::instance();
if (context->windowUnderMouse() == window())
context->clearWindowUnderMouse();
if (hasMouseCapture())
setMouseGrabEnabled(false);
unregisterDropSite();
@ -893,7 +896,7 @@ void QWindowsWindow::destroyWindow()
#endif // !Q_OS_WINCE
if (m_data.hwnd != GetDesktopWindow())
DestroyWindow(m_data.hwnd);
QWindowsContext::instance()->removeWindow(m_data.hwnd);
context->removeWindow(m_data.hwnd);
m_data.hwnd = 0;
}
}