summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2012-08-08 13:48:29 +0300
committerQt by Nokia <qt-info@nokia.com>2012-08-09 13:17:39 +0200
commit2ccd34fd20b72a1cd4125d67dd206d4f968a1b5d (patch)
tree8da02e7c5d0bf7b1a51a2da62940a315efdbcdd8 /src/plugins
parent5c6382099285768d441a589db392aa3b0c795517 (diff)
Use native handles for parent change check in QWindowsWindow.
QWindow::setParent() sets the parent to zero instead of the desired parent, if platform window has not yet been created for the parent. This caused QWindowsWindow::setParent() to skip setting the parent later, when correct window was specified, as the QWindow parent-child relationship hadn't changed. Fixed by changing the the check to use native handles instead. Task-number: QTBUG-26791 Change-Id: I292a1ddf746583a7268f2d07c20166995c0dd7d6 Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 6e0d9b5924..edb3e8c7a1 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -888,31 +888,35 @@ void QWindowsWindow::setParent(const QPlatformWindow *newParent)
if (QWindowsContext::verboseWindows)
qDebug() << __FUNCTION__ << window() << newParent;
- if (newParent != parent() && m_data.hwnd)
+ if (m_data.hwnd)
setParent_sys(newParent);
}
void QWindowsWindow::setParent_sys(const QPlatformWindow *parent) const
{
- HWND parentHWND = 0;
+ // Use GetAncestor instead of GetParent, as GetParent can return owner window for toplevels
+ HWND oldParentHWND = GetAncestor(m_data.hwnd, GA_PARENT);
+ HWND newParentHWND = 0;
if (parent) {
const QWindowsWindow *parentW = static_cast<const QWindowsWindow *>(parent);
- parentHWND = parentW->handle();
+ newParentHWND = parentW->handle();
}
- const bool wasTopLevel = window()->isTopLevel();
- const bool isTopLevel = parentHWND == 0;
+ if (newParentHWND != oldParentHWND) {
+ const bool wasTopLevel = window()->isTopLevel();
+ const bool isTopLevel = newParentHWND == 0;
- setFlag(WithinSetParent);
- SetParent(m_data.hwnd, parentHWND);
- clearFlag(WithinSetParent);
+ setFlag(WithinSetParent);
+ SetParent(m_data.hwnd, newParentHWND);
+ clearFlag(WithinSetParent);
- // WS_CHILD/WS_POPUP must be manually set/cleared in addition
- // to dialog frames, etc (see SetParent() ) if the top level state changes.
- if (wasTopLevel != isTopLevel) {
- const unsigned flags = isTopLevel ? unsigned(0) : unsigned(WindowCreationData::ForceChild);
- setWindowFlags_sys(window()->windowFlags(), flags);
+ // WS_CHILD/WS_POPUP must be manually set/cleared in addition
+ // to dialog frames, etc (see SetParent() ) if the top level state changes.
+ if (wasTopLevel != isTopLevel) {
+ const unsigned flags = isTopLevel ? unsigned(0) : unsigned(WindowCreationData::ForceChild);
+ setWindowFlags_sys(window()->windowFlags(), flags);
+ }
}
}