diff options
author | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2016-03-18 13:22:19 -0700 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@theqtcompany.com> | 2016-03-22 05:56:57 +0000 |
commit | 56384a854aeaa5d3275c158c80a07082949468da (patch) | |
tree | 2eb29e4462c7ef956d22d763088d65d91b1a5a9d /src/plugins/platforms/cocoa/qcocoamenubar.mm | |
parent | c228e01e1212a2ecd64d475980be04fc7b825bea (diff) |
QCocoaMenus: Use mix-in pattern to implement menu hierarchy
To solve menu item roles from their text, we need to find
its depth in the menubar hierarchy. Unfortunately, there's
no trivial way to access that hierarchy from the QPA side,
so we need to come with an ad-hoc solution.
Previously, we were using a dynamic proprety to keep track
of the 'parent' object. However, as the life span of the
different objects has changed since 09acf326dbc6b7b67f21a36,
we need a way to keep track of the parent's existence.
This is what we do in this patch by having both QCocoaMenu
and QCocoaMenuItem also inherit QCocoaMenuObject. This class'
sole role is to store the menu hierarchy's parent object and
wrap it in a QPointer.
Change-Id: Ia18d95171af76d26f6325eef04c77b40d99c4285
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoamenubar.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoamenubar.mm | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index ac4d29fc52..ac48a0e310 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -314,7 +314,7 @@ void QCocoaMenuBar::updateMenuBarImmediately() continue; NSMenuItem *item = mb->nativeItemForMenu(menu); menu->setAttachedItem(item); - SET_COCOA_MENU_ANCESTOR(menu, mb); + menu->setMenuParent(mb); // force a sync? mb->syncMenu(menu); menu->syncModalState(disableForModal); |