summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qcocoamenuloader_mac.mm7
-rw-r--r--src/gui/widgets/qmenu_mac.mm6
2 files changed, 11 insertions, 2 deletions
diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm
index 9ab077f..990571d 100644
--- a/src/gui/kernel/qcocoamenuloader_mac.mm
+++ b/src/gui/kernel/qcocoamenuloader_mac.mm
@@ -76,9 +76,14 @@ QT_USE_NAMESPACE
- (void)ensureAppMenuInMenu:(NSMenu *)menu
{
+ // The application menu is the menu in the menu bar that contains the
+ // 'Quit' item. When changing menu bar (e.g when swithing between
+ // windows with different menu bars), we never recreate this menu, but
+ // instead pull it out the current menu bar and place into the new one:
NSMenu *mainMenu = [NSApp mainMenu];
if ([NSApp mainMenu] == menu)
- return; // nothing to do!
+ return; // nothing to do (menu is the current menu bar)!
+
#ifndef QT_NAMESPACE
Q_ASSERT(mainMenu);
#endif
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index 9510cc6..8b371e5 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/gui/widgets/qmenu_mac.mm
@@ -774,8 +774,12 @@ QMacMenuAction::~QMacMenuAction()
&& menuItem != [getMenuLoader() quitMenuItem]) {
[menuItem setHidden:YES];
}
+ // Only clear the tag if it points to this action. Since items like
+ // 'Quit' is being reused, we sometimes end up redirecting the item
+ // before deleting the assosiated action.
+ if (action.data() == reinterpret_cast<QAction *>([menuItem tag]))
+ [menuItem setTag:nil];
}
- [menuItem setTag:nil];
[menuItem release];
#endif
}