Skip to content

Commit c923aa2

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

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

shell/browser/ui/cocoa/atom_menu_controller.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ - (void)menuWillOpen:(NSMenu*)menu {
375375
- (void)menuDidClose:(NSMenu*)menu {
376376
if (isMenuOpen_) {
377377
isMenuOpen_ = NO;
378-
model_->MenuWillClose();
378+
if (model_)
379+
model_->MenuWillClose();
379380
// Post async task so that itemSelected runs before the close callback
380381
// deletes the controller from the map which deallocates it
381382
if (!closeCallback.is_null()) {

0 commit comments

Comments
 (0)