Merge pull request #4164 from deepak1556/menu_toggle_crash_patch
browser: fix crash when switching to sibling menu from submenus
This commit is contained in:
commit
40557083f0
2 changed files with 6 additions and 16 deletions
|
@ -105,24 +105,17 @@ views::MenuItemView* MenuDelegate::GetSiblingMenu(
|
||||||
ui::MenuModel* model;
|
ui::MenuModel* model;
|
||||||
if (menu_bar_->GetMenuButtonFromScreenPoint(screen_point, &model, &button) &&
|
if (menu_bar_->GetMenuButtonFromScreenPoint(screen_point, &model, &button) &&
|
||||||
button->tag() != id_) {
|
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::PostTask(
|
||||||
content::BrowserThread::UI, FROM_HERE,
|
content::BrowserThread::UI, FROM_HERE,
|
||||||
base::Bind(&MenuDelegate::SwitchToSiblingMenu,
|
base::Bind(base::IgnoreResult(&views::MenuButton::Activate),
|
||||||
base::Unretained(this), button));
|
base::Unretained(button)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
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
|
} // namespace atom
|
||||||
|
|
|
@ -50,9 +50,6 @@ class MenuDelegate : public views::MenuDelegate {
|
||||||
views::MenuButton** button) override;
|
views::MenuButton** button) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Close this menu and run the menu of |button|.
|
|
||||||
void SwitchToSiblingMenu(views::MenuButton* button);
|
|
||||||
|
|
||||||
MenuBar* menu_bar_;
|
MenuBar* menu_bar_;
|
||||||
int id_;
|
int id_;
|
||||||
scoped_ptr<views::MenuDelegate> adapter_;
|
scoped_ptr<views::MenuDelegate> adapter_;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue