diff options
author | Norwegian Rock Cat <qt-info@nokia.com> | 2009-07-06 13:43:03 (GMT) |
---|---|---|
committer | Norwegian Rock Cat <qt-info@nokia.com> | 2009-07-06 13:43:03 (GMT) |
commit | e07e95da3d35a2ea1ab2b325df6c91620f948497 (patch) | |
tree | d13f72baa539cd3345cf8fa0a1c0d7f8323d4f7f /src/gui | |
parent | fd181167709283a2ceefa5285d6189fa7de23bb6 (diff) | |
download | Qt-e07e95da3d35a2ea1ab2b325df6c91620f948497.zip Qt-e07e95da3d35a2ea1ab2b325df6c91620f948497.tar.gz Qt-e07e95da3d35a2ea1ab2b325df6c91620f948497.tar.bz2 |
Fix issue where a mainwindow would show two size grips in Cocoa.
OK. this is a bit strange. It seems the topdata->resizer value is used
to control whether or not we should show a resize handle based on a
count (0 no, non-zero yes). Since we somehow decided that this value
will never be larger than 15, we made it 4-bits wide. There's a "Qt/Mac"
API, QWidgetPrivate::qt_mac_update_sizer(QWidget *, int = 0) which
would adjust this value by the int passed in.. We use that in several places, not excluding
the QStatusBar where we would pass 1 if we want to show, and -1 if we
didn't. Now if you subtract -1 from zero when you are 4 bits wide, well,
bad things happen. Therefore protect that (since if it's at zero we have
succeeded, we don't want to show the resizer). This seems to work well.
The private API is certainly an interesting way of solving the problem,
but is easy to abuse (for example, this code will break if resizer = 1
and we are passed -2 in the function.
Task-number: 257485
Reviewed-by: Prasanth Ullattil
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qwidget_mac.mm | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index ec9a049..f96d061 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -1526,12 +1526,16 @@ void QWidgetPrivate::toggleDrawers(bool visible) *****************************************************************************/ bool QWidgetPrivate::qt_mac_update_sizer(QWidget *w, int up) { + // I'm not sure what "up" is if(!w || !w->isWindow()) return false; QTLWExtra *topData = w->d_func()->topData(); QWExtra *extraData = w->d_func()->extraData(); - topData->resizer += up; + // topData->resizer is only 4 bits, so subtracting -1 from zero causes bad stuff + // to happen, prevent that here (you really want the thing hidden). + if (up >= 0 || topData->resizer != 0) + topData->resizer += up; OSWindowRef windowRef = qt_mac_window_for(OSViewRef(w->winId())); { #ifndef QT_MAC_USE_COCOA @@ -1544,7 +1548,6 @@ bool QWidgetPrivate::qt_mac_update_sizer(QWidget *w, int up) bool remove_grip = (topData->resizer || (w->windowFlags() & Qt::FramelessWindowHint) || (extraData->maxw && extraData->maxh && extraData->maxw == extraData->minw && extraData->maxh == extraData->minh)); - #ifndef QT_MAC_USE_COCOA WindowAttributes attr; GetWindowAttributes(windowRef, &attr); |