From 466c908681d25031cc89d49fccd7a90a4414ecbf Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 26 Aug 2009 08:55:37 +0200 Subject: Cocoa, the menus can be disabled after a modal dialog Why this happends is a bit blurry. From before, I know that cocoa is a bit buggy regarding setting a menu item hidden or not. The solution back then resulted in the function syncNSMenuItemEnabled in qmenu_mac.mm. This patch basically applies the same (silly) trick; disabling the menuitem before enabling it. This seems to force an update to the menu items enabled state. For the record: this is not a fix that I embrace. I hope we can remove it again some day. See task for how to reproduce. Task: 259600 Rev-By: alexis --- src/gui/widgets/qmenu_mac.mm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 47a8042..8e28abe 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -607,6 +607,13 @@ static inline void syncNSMenuItemVisiblity(NSMenuItem *menuItem, bool actionVisi [menuItem setHidden:!actionVisibility]; } +static inline void syncNSMenuItemEnabled(NSMenuItem *menuItem, bool enabled) +{ + [menuItem setEnabled:NO]; + [menuItem setEnabled:YES]; + [menuItem setEnabled:enabled]; +} + static inline void syncMenuBarItemsVisiblity(const QMenuBarPrivate::QMacMenuBarPrivate *mac_menubar) { const QList &menubarActions = mac_menubar->actionItems; @@ -659,12 +666,12 @@ void qt_mac_set_modal_state_helper_recursive(OSMenuRef menu, OSMenuRef merge, bo // The item should follow what the QAction has. if ([item tag]) { QAction *action = reinterpret_cast([item tag]); - [item setEnabled:action->isEnabled()]; + syncNSMenuItemEnabled(item, action->isEnabled()); } else { - [item setEnabled:YES]; + syncNSMenuItemEnabled(item, YES); } } else { - [item setEnabled:NO]; + syncNSMenuItemEnabled(item, NO); } } } -- cgit v0.12