summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2017-06-23 09:08:19 +0200
committerAndy Shaw <andy.shaw@qt.io>2017-07-03 09:42:13 +0000
commit3e8ebea95b634c7ded9ee0b884768155e9e7f686 (patch)
treec945e7bfe0c43a63ef0a3ca92a970ae8795c15eb /src/plugins
parent9b91784987831561c713aa1a57ac21ec49818d74 (diff)
Cocoa: Reset the target + action for a menuitem after showing a dialog
To make it more reliable and efficient we now do the reverse of what we are doing when redirecting the items. This will ensure that the actions are correctly reset to the original target and action. The original approach of updateMenubarImmediately() was not always doing this and it also does other unnecessary things as a result when all we need is to just reset the things we changed. Change-Id: Icefa38d47ec9434894f05caeed75fbf8bdfecb93 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
index 82c405baa6..4cdf004dd1 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
@@ -303,7 +303,23 @@ void QCocoaMenuBar::resetKnownMenuItemsToQt()
// Undo the effect of redirectKnownMenuItemsToFirstResponder():
// set the menu items' actions to itemFired and their targets to
// the QCocoaMenuDelegate.
- updateMenuBarImmediately();
+ foreach (QCocoaMenuBar *mb, static_menubars) {
+ foreach (QCocoaMenu *m, mb->m_menus) {
+ foreach (QCocoaMenuItem *i, m->items()) {
+ switch (i->effectiveRole()) {
+ case QPlatformMenuItem::CutRole:
+ case QPlatformMenuItem::CopyRole:
+ case QPlatformMenuItem::PasteRole:
+ case QPlatformMenuItem::SelectAllRole:
+ [i->nsItem() setTarget:m->nsMenu().delegate];
+ [i->nsItem() setAction:@selector(itemFired:)];
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
}
void QCocoaMenuBar::updateMenuBarImmediately()