Commit 32f8b1c3 authored by rdevlin.cronin's avatar rdevlin.cronin Committed by Commit bot

[Extensions Toolbar Mac] Fix crash in browser action context menus

Right now, there's a chance that the NSMenu can outlive the underlying menu
model (which is owned by the view controller). Make sure we reset the context
menu before destruction and before creating a new menu to correct this.

BUG=462175

Review URL: https://codereview.chromium.org/967883006

Cr-Commit-Position: refs/heads/master@{#319678}
parent 8d63f0cd
...@@ -411,6 +411,9 @@ void ToolbarActionViewDelegateBridge::DoShowContextMenu() { ...@@ -411,6 +411,9 @@ void ToolbarActionViewDelegateBridge::DoShowContextMenu() {
// We only need to do this because in Cocoa's memory management, removing the // We only need to do this because in Cocoa's memory management, removing the
// button from the toolbar doesn't synchronously dealloc it. // button from the toolbar doesn't synchronously dealloc it.
viewControllerDelegate_.reset(); viewControllerDelegate_.reset();
// Also reset the context menu, since it has a dependency on the backing
// controller (which owns its model).
contextMenuController_.reset();
} }
- (BOOL)isAnimating { - (BOOL)isAnimating {
...@@ -465,6 +468,9 @@ void ToolbarActionViewDelegateBridge::DoShowContextMenu() { ...@@ -465,6 +468,9 @@ void ToolbarActionViewDelegateBridge::DoShowContextMenu() {
if (testContextMenu_) if (testContextMenu_)
return testContextMenu_; return testContextMenu_;
// Make sure we delete any references to an old menu.
contextMenuController_.reset();
ui::MenuModel* contextMenu = viewController_->GetContextMenu(); ui::MenuModel* contextMenu = viewController_->GetContextMenu();
if (!contextMenu) if (!contextMenu)
return nil; return nil;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment