diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2009-11-25 14:38:45 (GMT) |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2009-11-25 14:44:29 (GMT) |
commit | 7f2f38d48b58b6b1ef90198bf2d03422826a5b08 (patch) | |
tree | 697637ed2bf8e250ef0bcc7a225ee3e4366c6381 | |
parent | 8ebc15eb2768fab8a9e746785e0c67efb4ace02b (diff) | |
download | Qt-7f2f38d48b58b6b1ef90198bf2d03422826a5b08.zip Qt-7f2f38d48b58b6b1ef90198bf2d03422826a5b08.tar.gz Qt-7f2f38d48b58b6b1ef90198bf2d03422826a5b08.tar.bz2 |
Cocoa: 'Quit' in menu bar does not work
If you have two window, each with its own menu bar that
has a 'Quit' action, we reuse the quit menu item when
switching between the windows. Now, it we deleteLater one of
the menu bars, the new menubar will update the 'Quit' item
just before deleteLater will come along and remote the update
again. This patch will fix this.
Task-number: QTBUG-4684
Reviewed-by: Prasanth
-rw-r--r-- | src/gui/kernel/qcocoamenuloader_mac.mm | 7 | ||||
-rw-r--r-- | src/gui/widgets/qmenu_mac.mm | 6 |
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 } |