summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-08-17 08:08:20 (GMT)
committerToby Tomkins <toby.tomkins@nokia.com>2010-08-19 00:29:54 (GMT)
commit0f7d34f1fc91fffd6f1264def27c6d353533050b (patch)
treef7af9bef11077a891e516f7813e4dfe1ba2c509d /src/gui
parent54bc94e03648902e55fcd26a858d5287ad71c261 (diff)
downloadQt-0f7d34f1fc91fffd6f1264def27c6d353533050b.zip
Qt-0f7d34f1fc91fffd6f1264def27c6d353533050b.tar.gz
Qt-0f7d34f1fc91fffd6f1264def27c6d353533050b.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 (cherry picked from commit cc6dc0aeefde881a95f5fea2b26f2f3d7bdc6e15)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qwidget_mac.mm22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index c2af6af..65128ec 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)];
+ }
}
}
}