Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Keep reference to MenuDelegate as a member (so it won't go out of sco…
Browse files Browse the repository at this point in the history
…pe and auto-close/destroy).

Fixes brave/browser-laptop#9470

Auditor: @darkdh
  • Loading branch information
bsclifton authored and bridiver committed Jun 17, 2017
1 parent a8ae8f0 commit fdf9f8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions atom/browser/ui/views/menu_bar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ MenuBar::MenuBar()
UpdateMenuBarColor();
SetLayoutManager(new views::BoxLayout(
views::BoxLayout::kHorizontal, 0, 0, 0));
menu_delegate_ = new MenuDelegate(this);
}

MenuBar::~MenuBar() {
if (menu_delegate_) delete menu_delegate_;
}

void MenuBar::SetMenu(AtomMenuModel* model) {
Expand Down Expand Up @@ -151,8 +153,7 @@ void MenuBar::OnMenuButtonClicked(views::MenuButton* source,
return;
}

MenuDelegate menu_delegate(this);
menu_delegate.RunMenu(menu_model_->GetSubmenuModelAt(id), source);
menu_delegate_->RunMenu(menu_model_->GetSubmenuModelAt(id), source);
}

void MenuBar::OnNativeThemeChanged(const ui::NativeTheme* theme) {
Expand Down
1 change: 1 addition & 0 deletions atom/browser/ui/views/menu_bar.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class MenuBar : public views::View,
void UpdateMenuBarColor();

SkColor background_color_;
MenuDelegate* menu_delegate_;

#if defined(USE_X11)
SkColor enabled_color_;
Expand Down

0 comments on commit fdf9f8e

Please sign in to comment.