From 56384a854aeaa5d3275c158c80a07082949468da Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 18 Mar 2016 13:22:19 -0700 Subject: QCocoaMenus: Use mix-in pattern to implement menu hierarchy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: J-P Nurmi Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoamenubar.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms/cocoa/qcocoamenubar.mm') 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); -- cgit v1.2.3