Windows QPA: Prevent usage of child windows as transient parent

When using foreign window integrations such as MFC/winmigrate,
it is possible that a child window is found which can cause issues
with modality. Loop up to top level.

Task-number: QTSOLBUG-71
Task-number: QTBUG-57159
Change-Id: Ib36e0f8f4f6b1e22ba1240013871facef2c0c1ab
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
Friedemann Kleint 2016-11-16 10:53:44 +01:00
parent 45948967bd
commit 79352528a1

View File

@ -1273,6 +1273,12 @@ void QWindowsWindow::updateTransientParent() const
if (const QWindowsWindow *tw = QWindowsWindow::windowsWindowOf(tp))
if (!tw->testFlag(WithinDestroy)) // Prevent destruction by parent window (QTBUG-35499, QTBUG-36666)
newTransientParent = tw->handle();
// QTSOLBUG-71: When using the MFC/winmigrate solution, it is possible that a child
// window is found, which can cause issues with modality. Loop up to top level.
while (newTransientParent && (GetWindowLongPtr(newTransientParent, GWL_STYLE) & WS_CHILD) != 0)
newTransientParent = GetParent(newTransientParent);
if (newTransientParent != oldTransientParent)
SetWindowLongPtr(m_data.hwnd, GWL_HWNDPARENT, LONG_PTR(newTransientParent));
}