QCocoaMenu: Explicitly remove NSMenu from supermenu on destruction

The d'tor of QCocoaMenu calls dismiss() to remove the current menu.
dismiss() calls cancelTracking, which doesn't always remove the
menu from its parent.

Remove the menu from its parent in addition.

Fixes: QTBUG-135634
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ic8e9b4172c3b2035b7e9ad1b576725923987abf2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Axel Spoerl 2025-06-03 15:39:03 +02:00 committed by Tor Arne Vestbø
parent 77f02471ed
commit 36ebec92e8

View File

@ -44,6 +44,16 @@ QCocoaMenu::~QCocoaMenu()
if (isOpen())
dismiss();
if (NSMenu *superMenu = m_nativeMenu.supermenu) {
for (NSMenuItem *item in superMenu.itemArray) {
if (item.submenu == m_nativeMenu) {
[superMenu removeItem:item];
break;
}
}
}
[m_nativeMenu release];
}