From 689606de91faecf91f1f92e8d355789d9be62d2f Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 7 Sep 2017 00:50:08 +0200 Subject: Cocoa: Update the known menu items when the QCocoaMenuBar is deleted If an application has more than one menubar, for instance, one for each mainwindow it has visible then once one is deleted it needs to ensure the application menu items are updated as appropriate. To do this the resetting of the known menu items is extended to cover all the application specific ones so that they can all be updated correctly. Task-number: QTBUG-62193 Change-Id: I61f46a4745f4e40b9283d40fa5a7473f2721c354 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoamenubar.mm | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 70fcb40774..3e466c9587 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -86,6 +86,7 @@ QCocoaMenuBar::~QCocoaMenuBar() // the menu bar was updated qDeleteAll(children()); updateMenuBarImmediately(); + resetKnownMenuItemsToQt(); } } @@ -306,16 +307,9 @@ void QCocoaMenuBar::resetKnownMenuItemsToQt() 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: + if (i->effectiveRole() >= QPlatformMenuItem::ApplicationSpecificRole) { [i->nsItem() setTarget:m->nsMenu().delegate]; [i->nsItem() setAction:@selector(itemFired:)]; - break; - default: - break; } } } -- cgit v1.2.3