| Index: ui/views/controls/menu/menu_controller.cc
|
| diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
|
| index aa002f26882d79ca43b067baf83c580db4b26f93..2accca917ad307be34bdb091ef31dc1aeef1fb59 100644
|
| --- a/ui/views/controls/menu/menu_controller.cc
|
| +++ b/ui/views/controls/menu/menu_controller.cc
|
| @@ -433,6 +433,12 @@ MenuItemView* MenuController::Run(Widget* parent,
|
| } else {
|
| showing_ = true;
|
|
|
| + // TODO(jonross): remove after tracking down the cause of
|
| + // (crbug.com/683087).
|
| + // If we are not showing we should be shutting down, this could lead to
|
| + // incorrect delegate states.
|
| + CHECK(!running_);
|
| +
|
| if (owner_)
|
| owner_->RemoveObserver(this);
|
| owner_ = parent;
|
| @@ -470,6 +476,10 @@ MenuItemView* MenuController::Run(Widget* parent,
|
| if (ViewsDelegate::GetInstance())
|
| ViewsDelegate::GetInstance()->AddRef();
|
|
|
| + // TODO(jonross): remove after tracking down the cause of (crbug.com/683087).
|
| + // About to either exit and run async, or nest message loop.
|
| + running_ = true;
|
| +
|
| if (async_run_)
|
| return nullptr;
|
|
|
| @@ -518,6 +528,11 @@ void MenuController::Cancel(ExitType type) {
|
| SetSelection(NULL, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT);
|
|
|
| if (!blocking_run_) {
|
| + // TODO(jonross): remove after tracking down the cause of
|
| + // (crbug.com/683087).
|
| + bool nested = delegate_stack_.size() > 1;
|
| + CHECK(!nested);
|
| + base::WeakPtr<MenuController> this_ref = AsWeakPtr();
|
| // If we didn't block the caller we need to notify the menu, which
|
| // triggers deleting us.
|
| DCHECK(selected);
|
| @@ -525,6 +540,7 @@ void MenuController::Cancel(ExitType type) {
|
| delegate_->OnMenuClosed(internal::MenuControllerDelegate::NOTIFY_DELEGATE,
|
| selected->GetRootMenuItem(), accept_event_flags_);
|
| // WARNING: the call to MenuClosed deletes us.
|
| + CHECK(!this_ref);
|
| return;
|
| }
|
|
|
| @@ -544,6 +560,12 @@ void MenuController::Cancel(ExitType type) {
|
|
|
| void MenuController::AddNestedDelegate(
|
| internal::MenuControllerDelegate* delegate) {
|
| + // TODO(jonross): remove after tracking down the cause of (crbug.com/683087).
|
| + for (auto delegates : delegate_stack_) {
|
| + // Having the same delegate in the stack could cause deletion order issues.
|
| + CHECK_NE(delegates.first, delegate);
|
| + }
|
| +
|
| delegate_stack_.push_back(std::make_pair(delegate, async_run_));
|
| delegate_ = delegate;
|
| }
|
| @@ -979,9 +1001,13 @@ int MenuController::OnPerformDrop(SubmenuView* source,
|
| drop_target = drop_target->GetParentMenuItem();
|
|
|
| if (!IsBlockingRun()) {
|
| + // TODO(jonross): remove after tracking down the cause of
|
| + // (crbug.com/683087).
|
| + base::WeakPtr<MenuController> this_ref = AsWeakPtr();
|
| delegate_->OnMenuClosed(
|
| internal::MenuControllerDelegate::DONT_NOTIFY_DELEGATE,
|
| item->GetRootMenuItem(), accept_event_flags_);
|
| + CHECK(!this_ref);
|
| }
|
|
|
| // WARNING: the call to MenuClosed deletes us.
|
| @@ -1380,6 +1406,7 @@ MenuController::MenuController(bool blocking,
|
| internal::MenuControllerDelegate* delegate)
|
| : blocking_run_(blocking),
|
| showing_(false),
|
| + running_(false),
|
| exit_type_(EXIT_NONE),
|
| did_capture_(false),
|
| result_(NULL),
|
| @@ -2658,6 +2685,9 @@ MenuItemView* MenuController::ExitMenuRun() {
|
|
|
| showing_ = false;
|
| did_capture_ = false;
|
| + // TODO(jonross): remove after tracking down the cause of
|
| + // (crbug.com/683087).
|
| + running_ = false;
|
| }
|
|
|
| MenuItemView* result = result_;
|
|
|