File tree Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -563,16 +563,22 @@ - (void)menuWillOpen:(NSMenu*)menu {
563563}
564564
565565- (void )menuDidClose : (NSMenu *)menu {
566- if (isMenuOpen_) {
567- isMenuOpen_ = NO ;
568- if (model_)
569- model_->MenuWillClose ();
570- // Post async task so that itemSelected runs before the close callback
571- // deletes the controller from the map which deallocates it
572- if (!closeCallback.is_null ()) {
573- content::GetUIThreadTaskRunner ({})->PostTask (FROM_HERE,
574- std::move (closeCallback));
575- }
566+ // If the menu is already closed, do nothing.
567+ if (!isMenuOpen_)
568+ return ;
569+
570+ // We should only respond to the top-level menu's close event.
571+ if (menu != menu_)
572+ return ;
573+
574+ isMenuOpen_ = NO ;
575+ if (model_)
576+ model_->MenuWillClose ();
577+ // Post async task so that itemSelected runs before the close callback
578+ // deletes the controller from the map which deallocates it
579+ if (!closeCallback.is_null ()) {
580+ content::GetUIThreadTaskRunner ({})->PostTask (FROM_HERE,
581+ std::move (closeCallback));
576582 }
577583}
578584
You can’t perform that action at this time.
0 commit comments