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:
Samuel Attard 2019-09-04 13:42:23 -07:00 committed by GitHub
parent 65ebb6e547
commit 8b523cf88a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()) {