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 <gabriel.dedietrich@qt.io>
This commit is contained in:
Andy Shaw 2017-09-07 00:50:08 +02:00
parent 452ad2bb13
commit 689606de91

View File

@ -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;
}
}
}