src/gui/widgets/qmenu_mac.mm
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
child 7 f7bc934e204c
--- a/src/gui/widgets/qmenu_mac.mm	Tue Jan 26 12:42:25 2010 +0200
+++ b/src/gui/widgets/qmenu_mac.mm	Tue Feb 02 00:43:10 2010 +0200
@@ -763,7 +763,9 @@
 {
 #ifdef QT_MAC_USE_COCOA
     [menu release];
-    if (action) {
+    // Update the menu item if this action still owns it. For some items
+    // (like 'Quit') ownership will be transferred between all menu bars...
+    if (action && action.data() == reinterpret_cast<QAction *>([menuItem tag])) {
         QAction::MenuRole role = action->menuRole();
         // Check if the item is owned by Qt, and should be hidden to keep it from causing
         // problems. Do it for everything but the quit menu item since that should always
@@ -774,8 +776,8 @@
                    && menuItem != [getMenuLoader() quitMenuItem]) {
             [menuItem setHidden:YES];
         }
+        [menuItem setTag:nil];
     }
-    [menuItem setTag:nil];
     [menuItem release];
 #endif
 }
@@ -1191,7 +1193,7 @@
 #endif
         }
 
-        QWidget *widget = qmenu ? qmenu->widgetItems.value(qmenu->actions.indexOf(action->action)) : 0;
+        QWidget *widget = qmenu ? qmenu->widgetItems.value(action->action) : 0;
         if (widget) {
 #ifndef QT_MAC_USE_COCOA
             ChangeMenuAttributes(action->menu, kMenuAttrDoNotCacheImage, 0);