From: Robo Date: Wed, 20 Jan 2016 02:59:44 +0000 (+0530) Subject: browser: fix crash when switching to sibling menu from submenus X-Git-Tag: v0.36.5~14^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=65325dc63f0d073991ff281fdaed973a11221362;p=electron.git browser: fix crash when switching to sibling menu from submenus --- diff --git a/atom/browser/ui/views/menu_delegate.cc b/atom/browser/ui/views/menu_delegate.cc index 8ef8bca7..f0ecf13b 100644 --- a/atom/browser/ui/views/menu_delegate.cc +++ b/atom/browser/ui/views/menu_delegate.cc @@ -105,24 +105,17 @@ views::MenuItemView* MenuDelegate::GetSiblingMenu( ui::MenuModel* model; if (menu_bar_->GetMenuButtonFromScreenPoint(screen_point, &model, &button) && button->tag() != id_) { - // Switch to sibling menu on next tick, otherwise crash may happen. + DCHECK(menu_runner_->IsRunning()); + menu_runner_->Cancel(); + // After canceling the menu, we need to wait until next tick + // so we are out of nested message loop. content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, - base::Bind(&MenuDelegate::SwitchToSiblingMenu, - base::Unretained(this), button)); + base::Bind(base::IgnoreResult(&views::MenuButton::Activate), + base::Unretained(button))); } return nullptr; } -void MenuDelegate::SwitchToSiblingMenu(views::MenuButton* button) { - menu_runner_->Cancel(); - // After canceling the menu, we need to wait until next tick so we are out of - // nested message loop. - content::BrowserThread::PostTask( - content::BrowserThread::UI, FROM_HERE, - base::Bind(base::IgnoreResult(&views::MenuButton::Activate), - base::Unretained(button))); -} - } // namespace atom diff --git a/atom/browser/ui/views/menu_delegate.h b/atom/browser/ui/views/menu_delegate.h index f83e5896..211ddb57 100644 --- a/atom/browser/ui/views/menu_delegate.h +++ b/atom/browser/ui/views/menu_delegate.h @@ -50,9 +50,6 @@ class MenuDelegate : public views::MenuDelegate { views::MenuButton** button) override; private: - // Close this menu and run the menu of |button|. - void SwitchToSiblingMenu(views::MenuButton* button); - MenuBar* menu_bar_; int id_; scoped_ptr adapter_;