Browse Source

fix: ensure modeL_ exists before calling delegate methods (#20116)

This is a speculative fix for a crash we are seeing in `menuDidClose`.  We
can't repro the crash but the traces have it happening in this method
and just by reading through the impl the only part that jumps out as
Might Crash is this `model_` call.  Other methods in the menu controller
check `model_` before using it so it probably makes sense to do that here
as well.
trop[bot] 5 years ago
parent
commit
c923aa2fde
1 changed files with 2 additions and 1 deletions
  1. 2 1
      shell/browser/ui/cocoa/atom_menu_controller.mm

+ 2 - 1
shell/browser/ui/cocoa/atom_menu_controller.mm

@@ -375,7 +375,8 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
 - (void)menuDidClose:(NSMenu*)menu {
   if (isMenuOpen_) {
     isMenuOpen_ = NO;
-    model_->MenuWillClose();
+    if (model_)
+      model_->MenuWillClose();
     // Post async task so that itemSelected runs before the close callback
     // deletes the controller from the map which deallocates it
     if (!closeCallback.is_null()) {