diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2010-08-17 08:08:20 (GMT) |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2010-08-17 09:23:49 (GMT) |
commit | cc6dc0aeefde881a95f5fea2b26f2f3d7bdc6e15 (patch) | |
tree | db4241e9ed534a6439064f65121e1690c3830f31 /src/gui/kernel/qwidget_mac.mm | |
parent | a76b8bf67696ae69888cc6237417e7c8f07f8da6 (diff) | |
download | Qt-cc6dc0aeefde881a95f5fea2b26f2f3d7bdc6e15.zip Qt-cc6dc0aeefde881a95f5fea2b26f2f3d7bdc6e15.tar.gz Qt-cc6dc0aeefde881a95f5fea2b26f2f3d7bdc6e15.tar.bz2 |
Cocoa: parent windows shows on screen when they should be hidden
The reason is the cocoa method that adds a window as a child of another,
it ends up showing both the parent and the child window regardless.
And this could in some cases also cause a crash.
So we therefore need to be careful when calling that function, and be
sure that the parent is actually visible. In addition, addChildWindow
reset the stacking level of the child window, and made e.g. normal
child windows pop in front of tool child windows. This could easily
be seen in e.g. Designer.
Task-number: QTBUG-12866
Reviewed-by: prasanth
Diffstat (limited to 'src/gui/kernel/qwidget_mac.mm')
-rw-r--r-- | src/gui/kernel/qwidget_mac.mm | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 8ae6a99..4ed4ccc 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2796,10 +2796,16 @@ void QWidgetPrivate::setSubWindowStacking(bool set) if (QWidget *parent = q->parentWidget()) { if (parent->testAttribute(Qt::WA_WState_Created)) { - if (set) - [qt_mac_window_for(parent) addChildWindow:qt_mac_window_for(q) ordered:NSWindowAbove]; - else + if (set) { + if (parent->isVisible()) { + NSWindow *childwin = qt_mac_window_for(q); + int childLevel = [childwin level]; + [qt_mac_window_for(parent) addChildWindow:childwin ordered:NSWindowAbove]; + [childwin setLevel:childLevel]; + } + } else { [qt_mac_window_for(parent) removeChildWindow:qt_mac_window_for(q)]; + } } } @@ -2807,10 +2813,14 @@ void QWidgetPrivate::setSubWindowStacking(bool set) for (int i=0; i<widgets.size(); ++i) { QWidget *child = widgets.at(i); if (child->isWindow() && child->testAttribute(Qt::WA_WState_Created) && child->isVisibleTo(q)) { - if (set) - [qt_mac_window_for(q) addChildWindow:qt_mac_window_for(child) ordered:NSWindowAbove]; - else + if (set) { + NSWindow *childwin = qt_mac_window_for(child); + int childLevel = [childwin level]; + [qt_mac_window_for(q) addChildWindow:childwin ordered:NSWindowAbove]; + [childwin setLevel:childLevel]; + } else { [qt_mac_window_for(q) removeChildWindow:qt_mac_window_for(child)]; + } } } } |