From 0d897a7fb6e2b2d6c2e8fe31aab1837ebd234b58 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 16 Aug 2012 13:03:32 +0300 Subject: [PATCH] Fix setParent_sys() to use native methods when checking for toplevel QWindowsWindow::setParent_sys() was checking if window was toplevel using non-native method, which caused wrong result in some cases involving native windows. Changed the toplevel check to utilize native method instead. Task-number: QTBUG-26826 Change-Id: I72ca17c53c1ed7611f141cee17b2edaaa80c6c17 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowswindow.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 773d3f7..8f37616 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -903,8 +903,15 @@ void QWindowsWindow::setParent_sys(const QPlatformWindow *parent) const } + // NULL handle means desktop window, which also has its proper handle -> disambiguate + HWND desktopHwnd = GetDesktopWindow(); + if (oldParentHWND == desktopHwnd) + oldParentHWND = 0; + if (newParentHWND == desktopHwnd) + newParentHWND = 0; + if (newParentHWND != oldParentHWND) { - const bool wasTopLevel = window()->isTopLevel(); + const bool wasTopLevel = oldParentHWND == 0; const bool isTopLevel = newParentHWND == 0; setFlag(WithinSetParent); -- 2.7.4