src/gui/widgets/qmenu_mac.mm
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
child 30 5dc02b23752f
--- a/src/gui/widgets/qmenu_mac.mm	Tue Feb 02 00:43:10 2010 +0200
+++ b/src/gui/widgets/qmenu_mac.mm	Wed Mar 31 11:06:36 2010 +0300
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 **
@@ -175,6 +175,22 @@
     return ret;
 }
 
+static void cancelAllMenuTracking()
+{
+#ifdef QT_MAC_USE_COCOA
+    QMacCocoaAutoReleasePool pool;
+    NSMenu *mainMenu = [NSApp mainMenu];
+    [mainMenu cancelTracking];
+    for (NSMenuItem *item in [mainMenu itemArray]) {
+        if ([item submenu]) {
+            [[item submenu] cancelTracking];
+        }
+    }
+#else
+    CancelMenuTracking(AcquireRootMenu(), true, 0);
+#endif
+}
+
 static bool actualMenuItemVisibility(const QMenuBarPrivate::QMacMenuBarPrivate *mbp,
                                      const QMacMenuAction *action)
 {
@@ -1830,6 +1846,12 @@
     mac_menubar = 0;
 
     if (qt_mac_current_menubar.qmenubar == q) {
+#ifdef QT_MAC_USE_COCOA
+        QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
+        [loader removeActionsFromAppMenu];
+#else
+        cancelAllMenuTracking();
+#endif
         extern void qt_event_request_menubarupdate(); //qapplication_mac.cpp
         qt_event_request_menubarupdate();
     }
@@ -1933,20 +1955,6 @@
     return qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget);
 }
 
-static void cancelAllMenuTracking()
-{
-#ifdef QT_MAC_USE_COCOA
-    QMacCocoaAutoReleasePool pool;
-    NSMenu *mainMenu = [NSApp mainMenu];
-    [mainMenu cancelTracking];
-    for (NSMenuItem *item in [mainMenu itemArray]) {
-        if ([item submenu]) {
-            [[item submenu] cancelTracking];
-        }
-    }
-#endif
-}
-
 /*!
   \internal