fix: make tray not block main process (#18880)

* fix: make tray not block main process

* make AtomMenuModel refcounted
This commit is contained in:
Shelley Vohr 2019-06-24 19:30:26 -07:00 committed by GitHub
parent 24ffc3cfb0
commit dc2cd8e780
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 4 deletions

View file

@ -13,7 +13,8 @@
namespace electron {
class AtomMenuModel : public ui::SimpleMenuModel {
class AtomMenuModel : public ui::SimpleMenuModel,
public base::RefCounted<AtomMenuModel> {
public:
class Delegate : public ui::SimpleMenuModel::Delegate {
public:
@ -48,7 +49,6 @@ class AtomMenuModel : public ui::SimpleMenuModel {
};
explicit AtomMenuModel(Delegate* delegate);
~AtomMenuModel() override;
void AddObserver(Observer* obs) { observers_.AddObserver(obs); }
void RemoveObserver(Observer* obs) { observers_.RemoveObserver(obs); }
@ -69,6 +69,9 @@ class AtomMenuModel : public ui::SimpleMenuModel {
AtomMenuModel* GetSubmenuModelAt(int index);
private:
friend class base::RefCounted<AtomMenuModel>;
~AtomMenuModel() override;
Delegate* delegate_; // weak ref.
std::map<int, base::string16> roles_; // command id -> role