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

Commit

Permalink
don't call delete if we're already in the destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed Sep 16, 2016
1 parent 3564083 commit 1c09ed9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions atom/browser/api/atom_api_menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ namespace api {

Menu::Menu(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
: model_(new AtomMenuModel(this)),
parent_(nullptr) {
parent_(nullptr),
is_destroyed_(false) {
InitWith(isolate, wrapper);
}

Menu::~Menu() {
is_destroyed_ = true;
MenuDestroyed();
}

Expand Down Expand Up @@ -157,7 +159,9 @@ bool Menu::IsVisibleAt(int index) const {

void Menu::MenuDestroyed() {
FOR_EACH_OBSERVER(MenuObserver, observers_, MenuDestroyed());
base::MessageLoop::current()->PostTask(FROM_HERE, GetDestroyClosure());
if (!is_destroyed_) {
base::MessageLoop::current()->PostTask(FROM_HERE, GetDestroyClosure());
}
}

// static
Expand Down
2 changes: 2 additions & 0 deletions atom/browser/api/atom_api_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class Menu : public mate::TrackableObject<Menu>,

base::ObserverList<MenuObserver> observers_;

bool is_destroyed_;

DISALLOW_COPY_AND_ASSIGN(Menu);
};

Expand Down

0 comments on commit 1c09ed9

Please sign in to comment.