Skip to content

Commit

Permalink
fix: ensure modeL_ exists before calling delegate methods (#20115)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
trop[bot] authored and codebytere committed Sep 6, 2019
1 parent 75dd6e5 commit 3925c09
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion atom/browser/ui/cocoa/atom_menu_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ - (void)menuWillOpen:(NSMenu*)menu {
- (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()) {
Expand Down

0 comments on commit 3925c09

Please sign in to comment.