Commit 1a06ec1b authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

cocoa: don't crash validating menu items

During browser startup or shutdown, there may be no tabs on the TabStripModel
while the browser's menu has already been created. In this case, it isn't safe
to ask the model about its active tab, so don't.

Bug: 730002
Change-Id: I18dfa17228dc061685dd62ba000d1607c6995290
Reviewed-on: https://chromium-review.googlesource.com/575876
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarYuri Wiitala <miu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487946}
parent 0f3440a6
......@@ -59,13 +59,19 @@ void UpdateToggleStateWithTag(NSInteger tag, id item, NSWindow* window) {
if (tag == IDC_WINDOW_MUTE_TAB) {
TabStripModel* model = browser->tab_strip_model();
SetToggleState(!model->WillContextMenuMute(model->active_index()), item);
// Menu items may be validated during browser startup, before the
// TabStripModel has been populated.
SetToggleState(
!model->empty() && !model->WillContextMenuMute(model->active_index()),
item);
return;
}
if (tag == IDC_WINDOW_PIN_TAB) {
TabStripModel* model = browser->tab_strip_model();
SetToggleState(!model->WillContextMenuPin(model->active_index()), item);
SetToggleState(
!model->empty() && !model->WillContextMenuPin(model->active_index()),
item);
return;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment