Fix crash with removed menus
Pick-to: 6.5 6.4 6.2 Fixes: QTBUG-111388 Change-Id: I9c9f0ad5cc02293197d7e77eeeec3ffa9d72a4af Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
2fffa21111
commit
8dfca2ee71
@ -355,8 +355,11 @@ void QCocoaMenuBar::insertWindowMenu()
|
|||||||
QList<QCocoaMenuItem*> QCocoaMenuBar::merged() const
|
QList<QCocoaMenuItem*> QCocoaMenuBar::merged() const
|
||||||
{
|
{
|
||||||
QList<QCocoaMenuItem*> r;
|
QList<QCocoaMenuItem*> r;
|
||||||
for (auto menu : std::as_const(m_menus))
|
for (auto menu : std::as_const(m_menus)) {
|
||||||
|
if (!menu)
|
||||||
|
continue;
|
||||||
r.append(menu->merged());
|
r.append(menu->merged());
|
||||||
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -400,7 +403,7 @@ bool QCocoaMenuBar::shouldDisable(QCocoaWindow *active) const
|
|||||||
QPlatformMenu *QCocoaMenuBar::menuForTag(quintptr tag) const
|
QPlatformMenu *QCocoaMenuBar::menuForTag(quintptr tag) const
|
||||||
{
|
{
|
||||||
for (auto menu : std::as_const(m_menus))
|
for (auto menu : std::as_const(m_menus))
|
||||||
if (menu->tag() == tag)
|
if (menu && menu->tag() == tag)
|
||||||
return menu;
|
return menu;
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -408,10 +411,13 @@ QPlatformMenu *QCocoaMenuBar::menuForTag(quintptr tag) const
|
|||||||
|
|
||||||
NSMenuItem *QCocoaMenuBar::itemForRole(QPlatformMenuItem::MenuRole role)
|
NSMenuItem *QCocoaMenuBar::itemForRole(QPlatformMenuItem::MenuRole role)
|
||||||
{
|
{
|
||||||
for (auto menu : std::as_const(m_menus))
|
for (auto menu : std::as_const(m_menus)) {
|
||||||
for (auto *item : menu->items())
|
if (menu) {
|
||||||
if (item->effectiveRole() == role)
|
for (auto *item : menu->items())
|
||||||
return item->nsItem();
|
if (item->effectiveRole() == role)
|
||||||
|
return item->nsItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user