Chromium Code Reviews| Index: ui/app_list/views/apps_grid_view.cc |
| diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc |
| index f825000b4f262642be76a8c229383070835eaadd..80675ce1c2d09adc4462b6b35b27eff1717d714d 100644 |
| --- a/ui/app_list/views/apps_grid_view.cc |
| +++ b/ui/app_list/views/apps_grid_view.cc |
| @@ -192,7 +192,7 @@ void AppsGridView::EnsureViewVisible(const views::View* view) { |
| void AppsGridView::InitiateDrag(AppListItemView* view, |
| Pointer pointer, |
| const ui::LocatedEvent& event) { |
| - if (drag_view_ || pulsing_blocks_model_.view_size()) |
| + if (drag_view_ || pulsing_blocks_model_.view_size() || !view) |
|
xiyuan
2013/06/03 18:03:34
nit: DCHECK(view) to catch the error as well since
Mr4D (OOO till 08-26)
2013/06/03 18:35:16
Done.
|
| return; |
| drag_view_ = view; |
| @@ -222,8 +222,11 @@ void AppsGridView::InitiateDrag(AppListItemView* view, |
| void AppsGridView::UpdateDrag(AppListItemView* view, |
| Pointer pointer, |
| const ui::LocatedEvent& event) { |
| - if (!dragging() && drag_view_ && |
| - ExceededDragThreshold(event.location() - drag_start_)) { |
| + // EndDrag was called before if |drag_view_| is NULL. |
| + if (!drag_view_) |
| + return; |
| + |
| + if (!dragging() && ExceededDragThreshold(event.location() - drag_start_)) { |
| drag_pointer_ = pointer; |
| // Move the view to the front so that it appears on top of other views. |
| ReorderChildView(drag_view_, -1); |
| @@ -258,10 +261,14 @@ void AppsGridView::UpdateDrag(AppListItemView* view, |
| } |
| void AppsGridView::EndDrag(bool cancel) { |
| + // EndDrag was called before if |drag_view_| is NULL. |
| + if (!drag_view_) |
| + return; |
| + |
| if (forward_events_to_drag_and_drop_host_) { |
| forward_events_to_drag_and_drop_host_ = false; |
| drag_and_drop_host_->EndDrag(cancel); |
| - } else if (!cancel && dragging() && drag_view_) { |
| + } else if (!cancel && dragging()) { |
| CalculateDropTarget(last_drag_point_, true); |
| if (IsValidIndex(drop_target_)) |
| MoveItemInModel(drag_view_, drop_target_); |
| @@ -276,10 +283,8 @@ void AppsGridView::EndDrag(bool cancel) { |
| drag_pointer_ = NONE; |
| drop_target_ = Index(); |
| - if (drag_view_) { |
| - drag_view_ = NULL; |
| - AnimateToIdealBounds(); |
| - } |
| + drag_view_ = NULL; |
| + AnimateToIdealBounds(); |
| page_flip_timer_.Stop(); |
| page_flip_target_ = -1; |