Cocoa QPA Menu: Clear menu items' Cocoa ancestor on destruction

Valid for both the item and the menu destructions.

Task-number: QTBUG-38685
Change-Id: I024b93c8bb8facefeaad5e8b6c7be6bf049898ea
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
Gabriel de Dietrich 2014-04-30 16:46:22 +02:00 committed by The Qt Project
parent 7eae50a52d
commit 8605f44097
2 changed files with 6 additions and 0 deletions

View File

@ -234,6 +234,10 @@ QCocoaMenu::QCocoaMenu() :
QCocoaMenu::~QCocoaMenu()
{
foreach (QCocoaMenuItem *item, m_menuItems) {
if (COCOA_MENU_ANCESTOR(item) == this)
SET_COCOA_MENU_ANCESTOR(item, 0);
}
QCocoaAutoReleasePool pool;
[m_nativeItem setSubmenu:nil];
[m_nativeMenu release];

View File

@ -105,6 +105,8 @@ QCocoaMenuItem::QCocoaMenuItem() :
QCocoaMenuItem::~QCocoaMenuItem()
{
if (m_menu && COCOA_MENU_ANCESTOR(m_menu) == this)
SET_COCOA_MENU_ANCESTOR(m_menu, 0);
if (m_merged) {
[m_native setHidden:YES];
} else {