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:
parent
1a79093378
commit
21949e2f0c
4 changed files with 6 additions and 18 deletions
|
@ -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
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
|
||||
#include "atom/browser/api/atom_api_menu.h"
|
||||
|
||||
namespace views {
|
||||
class MenuRunner;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
@ -23,8 +19,6 @@ class MenuViews : public Menu {
|
|||
virtual void Popup(Window* window) OVERRIDE;
|
||||
|
||||
private:
|
||||
scoped_ptr<views::MenuRunner> menu_runner_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MenuViews);
|
||||
};
|
||||
|
||||
|
|
|
@ -34,16 +34,14 @@ void MenuDelegate::RunMenu(ui::MenuModel* model, views::MenuButton* button) {
|
|||
id_ = button->tag();
|
||||
views::MenuItemView* item = BuildMenu(model);
|
||||
|
||||
menu_runner_.reset(new views::MenuRunner(item));
|
||||
views::MenuRunner::RunResult result = menu_runner_->RunMenuAt(
|
||||
views::MenuRunner menu_runner(item);
|
||||
ignore_result(menu_runner.RunMenuAt(
|
||||
button->GetWidget()->GetTopLevelWidget(),
|
||||
button,
|
||||
bounds,
|
||||
views::MenuItemView::TOPRIGHT,
|
||||
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));
|
||||
}
|
||||
|
||||
views::MenuItemView* MenuDelegate::BuildMenu(ui::MenuModel* model) {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
namespace views {
|
||||
class MenuModelAdapter;
|
||||
class MenuRunner;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
|
@ -59,7 +58,6 @@ class MenuDelegate : public views::MenuDelegate {
|
|||
views::MenuDelegate* delegate() const { return delegates_[id_]; }
|
||||
|
||||
MenuBar* menu_bar_;
|
||||
scoped_ptr<views::MenuRunner> menu_runner_;
|
||||
|
||||
// Current item's id.
|
||||
int id_;
|
||||
|
|
Loading…
Reference in a new issue