Skip to content

Commit 3925c09

Browse files
trop[bot]codebytere
authored andcommitted
fix: ensure modeL_ exists before calling delegate methods (electron#20115)
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.
1 parent 75dd6e5 commit 3925c09

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

atom/browser/ui/cocoa/atom_menu_controller.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ - (void)menuWillOpen:(NSMenu*)menu {
372372
- (void)menuDidClose:(NSMenu*)menu {
373373
if (isMenuOpen_) {
374374
isMenuOpen_ = NO;
375-
model_->MenuWillClose();
375+
if (model_)
376+
model_->MenuWillClose();
376377
// Post async task so that itemSelected runs before the close callback
377378
// deletes the controller from the map which deallocates it
378379
if (!closeCallback.is_null()) {

0 commit comments

Comments
 (0)