QCocoaMenu: Have the menu delegate return the right amount of items

In some cases we move menu items around, therefore we should
not rely on QCocoaMenu::items() being the actual items inside
the menu. But, since the NSMenu is updated before hand, we can
rely on NSMenu.numberOfItems instead.

Change-Id: Icd4497beca4f52a6d38408eeaa2e6ec71b579685
Task-number: QTBUG-52931
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Gabriel de Dietrich 2016-04-22 11:52:29 -07:00 committed by Timur Pocheptsov
parent 2e9fc0d3f0
commit 6844f60dae

View File

@ -99,7 +99,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate);
- (NSInteger)numberOfItemsInMenu:(NSMenu *)menu
{
Q_ASSERT(m_menu->nsMenu() == menu);
return m_menu->items().count();
return menu.numberOfItems;
}
- (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)item atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel