diff --git a/atom/browser/api/atom_api_menu.cc b/atom/browser/api/atom_api_menu.cc index f8964421b8e8..651e2067e185 100644 --- a/atom/browser/api/atom_api_menu.cc +++ b/atom/browser/api/atom_api_menu.cc @@ -23,9 +23,13 @@ Menu::Menu(v8::Isolate* isolate, v8::Local wrapper) : model_(new AtomMenuModel(this)), parent_(nullptr) { InitWith(isolate, wrapper); + model_->AddObserver(this); } Menu::~Menu() { + if (model_) { + model_->RemoveObserver(this); + } } void Menu::AfterInit(v8::Isolate* isolate) { diff --git a/atom/browser/api/atom_api_menu.h b/atom/browser/api/atom_api_menu.h index 316dbd36d3e3..aafd8f893967 100644 --- a/atom/browser/api/atom_api_menu.h +++ b/atom/browser/api/atom_api_menu.h @@ -18,7 +18,8 @@ namespace atom { namespace api { class Menu : public mate::TrackableObject, - public AtomMenuModel::Delegate { + public AtomMenuModel::Delegate, + public AtomMenuModel::Observer { public: static mate::WrappableBase* New(mate::Arguments* args);