views: Don't retain MenuRunner on heap.

Sometimes the MenuHost would crash when the window is closed, the author
didn't recommend using MenuRunner on stack, but since we always run the
menu synchronously, this is no problem.
This commit is contained in:
Cheng Zhao 2014-07-21 21:42:01 +08:00
parent 1a79093378
commit 21949e2f0c
4 changed files with 6 additions and 18 deletions

View file

@ -25,16 +25,14 @@ void MenuViews::Popup(Window* window) {
cursor = gfx::win::ScreenToDIPPoint(cursor);
#endif
menu_runner_.reset(new views::MenuRunner(model()));
views::MenuRunner::RunResult result = menu_runner_->RunMenuAt(
views::MenuRunner menu_runner(model());
ignore_result(menu_runner.RunMenuAt(
static_cast<NativeWindowViews*>(window->window())->widget(),
NULL,
gfx::Rect(cursor, gfx::Size()),
views::MenuItemView::TOPLEFT,
ui::MENU_SOURCE_MOUSE,
views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU);
if (result == views::MenuRunner::MENU_DELETED)
LOG(ERROR) << "Menu deleted when running";
views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU));
}
// static