Chromium Code Reviews| Index: ui/app_list/views/search_result_view.cc |
| diff --git a/ui/app_list/views/search_result_view.cc b/ui/app_list/views/search_result_view.cc |
| index ba9575a7e08e470fea9b5c18f89cd057572230a2..9124a81bcd375118a1102ead5933c4341bbe85d3 100644 |
| --- a/ui/app_list/views/search_result_view.cc |
| +++ b/ui/app_list/views/search_result_view.cc |
| @@ -172,7 +172,9 @@ void SearchResultView::Layout() { |
| } |
| bool SearchResultView::OnKeyPressed(const ui::KeyEvent& event) { |
| - DCHECK(result_); |
| + // |result_| could be NULL when result list is changing. |
| + if (!result_) |
| + return false; |
| switch (event.key_code()) { |
| case ui::VKEY_TAB: { |
| @@ -304,7 +306,7 @@ void SearchResultView::OnIsInstallingChanged() { |
| } |
| void SearchResultView::OnPercentDownloadedChanged() { |
| - progress_bar_->SetValue(result_->percent_downloaded() / 100.0); |
| + progress_bar_->SetValue(result_ ? result_->percent_downloaded() / 100.0 : 0); |
| } |
| void SearchResultView::OnItemInstalled() { |
| @@ -317,7 +319,10 @@ void SearchResultView::OnItemUninstalled() { |
| void SearchResultView::OnSearchResultActionActivated(size_t index, |
| int event_flags) { |
| - DCHECK(result_); |
| + // |result_| could be NULL when result list is changing. |
| + if (!result_) |
| + return; |
| + |
| DCHECK_LT(index, result_->actions().size()); |
| delegate_->SearchResultActionActivated(this, index, event_flags); |
| @@ -326,7 +331,7 @@ void SearchResultView::OnSearchResultActionActivated(size_t index, |
| void SearchResultView::ShowContextMenuForView(views::View* source, |
| const gfx::Point& point, |
| ui::MenuSourceType source_type) { |
| - ui::MenuModel* menu_model = result_->GetContextMenuModel(); |
| + ui::MenuModel* menu_model = result_ ? result_->GetContextMenuModel() : NULL; |
|
Matt Giuca
2014/01/07 22:55:08
Optional nit: It seems a little weird in the NULL
xiyuan
2014/01/07 23:12:44
Done.
|
| if (!menu_model) |
| return; |