diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2009-11-25 15:00:41 (GMT) |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2009-11-25 15:00:41 (GMT) |
commit | 4d7b7dc0bdd12188d92a5d05a35991af7b53cc81 (patch) | |
tree | 8f37de21eab3c7ed4d70c945db3e3792fc34a764 | |
parent | 7f2f38d48b58b6b1ef90198bf2d03422826a5b08 (diff) | |
download | Qt-4d7b7dc0bdd12188d92a5d05a35991af7b53cc81.zip Qt-4d7b7dc0bdd12188d92a5d05a35991af7b53cc81.tar.gz Qt-4d7b7dc0bdd12188d92a5d05a35991af7b53cc81.tar.bz2 |
Mac: deleting a menu item might clear items in other menus
The reson is that some menu items are reused across all menu bars.
So we need to check that a menu actually still owns the item before
clearing or hiding its data.
Reviewed-by: Prasanth
-rw-r--r-- | src/gui/widgets/qmenu_mac.mm | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 8b371e5..30bbd31 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -763,7 +763,9 @@ QMacMenuAction::~QMacMenuAction() { #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,11 +776,7 @@ 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 |