diff options
author | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2016-07-11 13:00:15 -0700 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2016-07-13 17:48:06 +0000 |
commit | 21c8a66a152e3184d8f965dc4cf2a1bee234780d (patch) | |
tree | b53fa20d771b15f15ee29b08fa8e88d1376e45d9 /src/plugins/platforms | |
parent | 1e843b41b6b2ba164615543a5683800d074e60f4 (diff) |
QCocoaMenuBar: Sync items only when they are attached to a menu
Another one of Cocoa's capricious behaviors. Evidence shows that
the menu item's submenu property needs to be set before we can
set the item's hidden property. We ensure this is the case by
getting the NSMenuItem through QCocoaMenu::attachedItem() instead
of QCocoaMenuBar::nativeItemForMenu() in QCocoaMenuBar::syncMenu().
Change-Id: Id50356dae5f556fa3d745ba9a5982e5a72bf0ac2
Task-number: QTBUG-54637
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Jason Haslam <jason@scitools.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoamenubar.mm | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index a534d2064e..9b03ea17c4 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -173,9 +173,11 @@ void QCocoaMenuBar::syncMenu(QPlatformMenu *menu) } } - NSMenuItem *nativeMenuItem = nativeItemForMenu(cocoaMenu); - nativeMenuItem.title = cocoaMenu->nsMenu().title; - nativeMenuItem.hidden = shouldHide; + if (NSMenuItem *attachedItem = cocoaMenu->attachedItem()) { + // Non-nil attached item means the item's submenu is set + attachedItem.title = cocoaMenu->nsMenu().title; + attachedItem.hidden = shouldHide; + } } NSMenuItem *QCocoaMenuBar::nativeItemForMenu(QCocoaMenu *menu) const |