From 583cc925ac93ed3bcc8a958bffec281f80f8c361 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 21 Jun 2016 15:25:14 -0700 Subject: [PATCH 1/2] Map roles by command id --- atom/browser/ui/atom_menu_model.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/atom/browser/ui/atom_menu_model.cc b/atom/browser/ui/atom_menu_model.cc index 9add7a22715e..369684dd3f21 100644 --- a/atom/browser/ui/atom_menu_model.cc +++ b/atom/browser/ui/atom_menu_model.cc @@ -17,12 +17,14 @@ AtomMenuModel::~AtomMenuModel() { } void AtomMenuModel::SetRole(int index, const base::string16& role) { - roles_[index] = role; + int command_id = GetCommandIdAt(index); + roles_[command_id] = role; } base::string16 AtomMenuModel::GetRoleAt(int index) { - if (ContainsKey(roles_, index)) - return roles_[index]; + int command_id = GetCommandIdAt(index); + if (ContainsKey(roles_, command_id)) + return roles_[command_id]; else return base::string16(); } From 812dea9a8b80a05d8fda6e176dd2314f4e6aad9b Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 21 Jun 2016 15:28:02 -0700 Subject: [PATCH 2/2] Add comment about map key/values --- atom/browser/ui/atom_menu_model.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/ui/atom_menu_model.h b/atom/browser/ui/atom_menu_model.h index d091df9fb570..1112949e7efa 100644 --- a/atom/browser/ui/atom_menu_model.h +++ b/atom/browser/ui/atom_menu_model.h @@ -42,7 +42,7 @@ class AtomMenuModel : public ui::SimpleMenuModel { private: Delegate* delegate_; // weak ref. - std::map roles_; + std::map roles_; // command id -> role base::ObserverList observers_; DISALLOW_COPY_AND_ASSIGN(AtomMenuModel);