Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: ui/app_list/views/apps_grid_view.cc

Issue 466693002: Fix app list DCHECKs getting hit when model updates occur during dragging (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 f1f1a05bf58cce6dbdf8a79c32e7ee5f9bf442d3..00141ffd1f19f6b96dc0ae134ab943db8a26342a 100644
--- a/ui/app_list/views/apps_grid_view.cc
+++ b/ui/app_list/views/apps_grid_view.cc
@@ -556,7 +556,8 @@ void AppsGridView::OnGotShortcutPath(
bool AppsGridView::UpdateDragFromItem(Pointer pointer,
const ui::LocatedEvent& event) {
- DCHECK(drag_view_);
+ if (!drag_view_)
+ return false; // Drag canceled.
gfx::Point drag_point_in_grid_view;
ExtractDragLocation(event, &drag_point_in_grid_view);
@@ -578,9 +579,8 @@ void AppsGridView::UpdateDrag(Pointer pointer, const gfx::Point& point) {
if (folder_delegate_)
UpdateDragStateInsideFolder(pointer, point);
- // EndDrag was called before if |drag_view_| is NULL.
if (!drag_view_)
- return;
+ return; // Drag canceled.
if (RunSynchronousDrag())
return;
@@ -674,6 +674,14 @@ void AppsGridView::EndDrag(bool cancel) {
return;
}
+ if (IsDraggingForReparentInRootLevelGridView()) {
+ // An EndDrag can be received during a reparent via a model change. This
+ // is always a cancel and needs to be forwarded to the folder.
+ DCHECK(cancel);
+ delegate_->CancelDragInActiveFolder();
+ return;
+ }
+
if (!cancel && dragging()) {
// Regular drag ending path, ie, not for reparenting.
CalculateDropTarget(last_drag_point_, true);
@@ -797,6 +805,9 @@ void AppsGridView::InitiateDragFromReparentItemInRootLevelGridView(
void AppsGridView::UpdateDragFromReparentItem(Pointer pointer,
const gfx::Point& drag_point) {
+ // Note that if a cancel ocurrs while reparenting, the |drag_view_| in both
+ // root and folder grid views is cleared, so the check in UpdateDragFromItem()
+ // for |drag_view_| being NULL (in the folder grid) is sufficient.
DCHECK(drag_view_);
DCHECK(IsDraggingForReparentInRootLevelGridView());

Powered by Google App Engine
This is Rietveld 408576698