Cocoa integration - avoid dangling menuitem pointer

Since QCocoaMenu can live longer than its m_attachedItem pointer,
this pointer is becoming invalid after QCocoaMenuItem deleted
(and its 'm_native' was released).

Task-number: QTBUG-53251
Change-Id: I6d97b75b2c09e2443cd21415c5db94206d5d89ce
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
This commit is contained in:
Timur Pocheptsov 2016-05-06 13:49:01 +02:00
parent 45bec92e7a
commit 4e0b76d810

View File

@ -110,6 +110,8 @@ QCocoaMenuItem::~QCocoaMenuItem()
if (m_merged) {
[m_native setHidden:YES];
} else {
if (m_menu && m_menu->attachedItem() == m_native)
m_menu->setAttachedItem(nil);
[m_native release];
}