From 4d7b7dc0bdd12188d92a5d05a35991af7b53cc81 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 25 Nov 2009 16:00:41 +0100 Subject: 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 --- src/gui/widgets/qmenu_mac.mm | 10 ++++------ 1 file 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([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([menuItem tag])) - [menuItem setTag:nil]; + [menuItem setTag:nil]; } [menuItem release]; #endif -- cgit v0.12