mirror of
https://github.com/electron/electron.git
synced 2026-01-28 00:38:35 -05:00
fix: ensure modeL_ exists before calling delegate methods (#20111)
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.
This commit is contained in:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user