From bef4c8479988ea2d09384804c6b604c4a976b1d1 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Sat, 27 Jan 2018 10:40:50 -0500 Subject: [PATCH] turn class into observer --- atom/browser/api/atom_api_menu.cc | 4 ++++ atom/browser/api/atom_api_menu.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) 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);