src/gui/widgets/qmenu_mac.mm
branchRCL_3
changeset 5 d3bac044e0f0
parent 4 3b1da2848fc7
--- a/src/gui/widgets/qmenu_mac.mm	Fri Feb 19 23:40:16 2010 +0200
+++ b/src/gui/widgets/qmenu_mac.mm	Fri Mar 12 15:46:37 2010 +0200
@@ -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