summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoamenu.mm
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-02-19 17:41:33 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-26 14:20:59 +0100
commitbf0336a02502b3ed4d399c1cf5b4a56b1e858d42 (patch)
tree42d86808337ad5998d75de9f1f71ceac529dca9d /src/plugins/platforms/cocoa/qcocoamenu.mm
parent15ec9907f968f3c4ebe461617b448f5c8d05e5c5 (diff)
Cocoa Menus: Give platform menu ownership back to QWidgets
We don't want to be in the situation where a QCocoaMenuItem owns a QCocoaMenu (because that item is a submenu), and then the actual QMenu "sees" that same QCocoaMenu being deleted. Instead, since all the QCocoaMenu* classes inherit QObject, we rely on meta-object properties to set the hierarchy and climb the hierarchy when guessing the menu item's role. This ammends most of commit 370e89f06465a4d61c7b. Task-number: QTBUG-36785 Change-Id: I0e03acb593e93061c8c6c1fdd161669cf0d2a293 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoamenu.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index aa6b71df31..35e8fdebb4 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -269,7 +269,7 @@ void QCocoaMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *
QCocoaMenuItem *cocoaItem = static_cast<QCocoaMenuItem *>(menuItem);
QCocoaMenuItem *beforeItem = static_cast<QCocoaMenuItem *>(before);
- menuItem->setParent(this);
+ SET_COCOA_MENU_ANCESTOR(menuItem, this);
cocoaItem->sync();
if (beforeItem) {
int index = m_menuItems.indexOf(beforeItem);
@@ -326,8 +326,8 @@ void QCocoaMenu::removeMenuItem(QPlatformMenuItem *menuItem)
return;
}
- if (menuItem->parent() == this)
- menuItem->setParent(0);
+ if (COCOA_MENU_ANCESTOR(menuItem) == this)
+ SET_COCOA_MENU_ANCESTOR(menuItem, 0);
m_menuItems.removeOne(cocoaItem);
if (!cocoaItem->isMerged()) {
@@ -551,7 +551,7 @@ void QCocoaMenu::syncModalState(bool modal)
void QCocoaMenu::setMenuBar(QCocoaMenuBar *menuBar)
{
m_menuBar = menuBar;
- setParent(menuBar);
+ SET_COCOA_MENU_ANCESTOR(this, menuBar);
}
QCocoaMenuBar *QCocoaMenu::menuBar() const