Skip to content

Commit

Permalink
Cocoa: When validating menus, account for modal window only if active
Browse files Browse the repository at this point in the history
When a modal window is WindowModal then it is possible for another top
level window to be active and therefore the menus shown may be valid
for the window. So we can still allow the menu items to be validated in
the context of that window.

Fixes: QTBUG-74088
Pick-to: 6.0 5.15
Change-Id: Ifb9c3fe12654b2972e0e3c368dc093fae1ed4cc8
Reviewed-by: Tor Arne Vestbø <[email protected]>
  • Loading branch information
AndyShawQt committed Jan 29, 2021
1 parent 8f9222d commit 115bcdb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/plugins/platforms/cocoa/qnsview_menus.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ - (BOOL)validateMenuItem:(NSMenuItem*)item
if (platformItem->menu())
return YES;

// Check if a modal dialog is active. Validate only menu
// items belonging to this view's window own menu bar.
if (QGuiApplication::modalWindow()) {
// Check if a modal dialog is active. If so, enable only menu
// items explicitly belonging to this window's own menu bar.
if (QGuiApplication::modalWindow() && QGuiApplication::modalWindow()->isActive()) {
QCocoaMenuBar *menubar = nullptr;

QObject *menuParent = platformItem->menuParent();
Expand All @@ -84,7 +84,6 @@ - (BOOL)validateMenuItem:(NSMenuItem*)item
menuParent = menuObject->menuParent();
}

// we have no menubar parent for the application menu items, e.g About and Preferences
if (!menubar || menubar->cocoaWindow() != self.platformWindow)
return NO;
}
Expand Down

0 comments on commit 115bcdb

Please sign in to comment.