summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qmenu_mac.mm
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-10-20 08:11:00 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-10-20 12:31:22 (GMT)
commitce03601e522ab10381f375c7bfd8862938d6955a (patch)
tree54f36b1aac1fd36640b6ddb3d321548d9e99fb6e /src/gui/widgets/qmenu_mac.mm
parentc238f7b7e299e742e71fdb043a7bc81bbfd6c419 (diff)
downloadQt-ce03601e522ab10381f375c7bfd8862938d6955a.zip
Qt-ce03601e522ab10381f375c7bfd8862938d6955a.tar.gz
Qt-ce03601e522ab10381f375c7bfd8862938d6955a.tar.bz2
Mac: fix bug when reparenting non-native menu bars
If we reparent a naive menu bar inside a widget that has a menu bar from before, the old menu bar is lost. This patch makes sure that we don't set the new menu bar in this case, but let it remain as-is in case the widget is reparanted out again later. Rev-By: MortenS
Diffstat (limited to 'src/gui/widgets/qmenu_mac.mm')
-rw-r--r--src/gui/widgets/qmenu_mac.mm20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index cee38ee..b238faf 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/gui/widgets/qmenu_mac.mm
@@ -1771,6 +1771,16 @@ QMenuBarPrivate::QMacMenuBarPrivate::removeAction(QMacMenuAction *action)
actionItems.removeAll(action);
}
+bool QMenuBarPrivate::macWidgetHasNativeMenubar(QWidget *widget)
+{
+ // This function is different from q->isNativeMenuBar(), as
+ // it returns true only if a native menu bar is actually
+ // _created_.
+ if (!widget)
+ return false;
+ return menubars()->contains(widget->window());
+}
+
void
QMenuBarPrivate::macCreateMenuBar(QWidget *parent)
{
@@ -1778,16 +1788,22 @@ QMenuBarPrivate::macCreateMenuBar(QWidget *parent)
static int dontUseNativeMenuBar = -1;
// We call the isNativeMenuBar function here
// because that will make sure that local overrides
- // are dealt with correctly.
+ // are dealt with correctly. q->isNativeMenuBar() will, if not
+ // overridden, depend on the attribute Qt::AA_DontUseNativeMenuBar:
bool qt_mac_no_native_menubar = !q->isNativeMenuBar();
if (qt_mac_no_native_menubar == false && dontUseNativeMenuBar < 0) {
+ // The menubar is set to be native. Let's check (one time only
+ // for all menubars) if this is OK with the rest of the environment.
+ // As a result, Qt::AA_DontUseNativeMenuBar is set. NB: the application
+ // might still choose to not respect, or change, this flag.
bool isPlugin = QApplication::testAttribute(Qt::AA_MacPluginApplication);
bool environmentSaysNo = !qgetenv("QT_MAC_NO_NATIVE_MENUBAR").isEmpty();
dontUseNativeMenuBar = isPlugin || environmentSaysNo;
QApplication::instance()->setAttribute(Qt::AA_DontUseNativeMenuBar, dontUseNativeMenuBar);
qt_mac_no_native_menubar = !q->isNativeMenuBar();
}
- if (!qt_mac_no_native_menubar) {
+ if (qt_mac_no_native_menubar == false) {
+ // INVARIANT: Use native menubar.
extern void qt_event_request_menubarupdate(); //qapplication_mac.cpp
qt_event_request_menubarupdate();
if (!parent && !fallback) {