Skip to content

Commit 0686613

Browse files
committed
[WIN] Fix: crash when Back/Forward key is received
1 parent b871dfa commit 0686613

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/api/menu/menu_delegate_win.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ bool MenuDelegate::IsCommandIdEnabled(int command_id) const {
4747
return false;
4848

4949
MenuItem* item = dispatcher_host_->GetApiObject<MenuItem>(command_id);
50+
if (!item)
51+
return false;
5052
return item->is_enabled_;
5153
}
5254

@@ -55,6 +57,8 @@ bool MenuDelegate::IsItemForCommandIdDynamic(int command_id) const {
5557
return false;
5658

5759
MenuItem* item = dispatcher_host_->GetApiObject<MenuItem>(command_id);
60+
if (!item)
61+
return false;
5862
return item->is_modified_;
5963
}
6064

@@ -66,6 +70,8 @@ string16 MenuDelegate::GetLabelForCommandId(int command_id) const {
6670
bool MenuDelegate::GetIconForCommandId(int command_id,
6771
gfx::Image* icon) const {
6872
MenuItem* item = dispatcher_host_->GetApiObject<MenuItem>(command_id);
73+
if (!item)
74+
return false;
6975
if (item->icon_.IsEmpty())
7076
return false;
7177

@@ -78,6 +84,8 @@ void MenuDelegate::ExecuteCommand(int command_id, int event_flags) {
7884
return;
7985

8086
MenuItem* item = dispatcher_host_->GetApiObject<MenuItem>(command_id);
87+
if (!item)
88+
return;
8189
item->OnClick();
8290
}
8391

@@ -86,6 +94,8 @@ bool MenuDelegate::HasIcon(int command_id) {
8694
return false;
8795

8896
MenuItem* item = dispatcher_host_->GetApiObject<MenuItem>(command_id);
97+
if (!item)
98+
return false;
8999
return !item->icon_.IsEmpty();
90100
}
91101

0 commit comments

Comments
 (0)