From d027815092005de1a63d24ab0c06ea0f982b9843 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Mon, 21 Apr 2014 17:58:55 +0200 Subject: Fix NPE if a moved cell does not have a parent This NPE should actually never happen. It did however and crashed Trebuchet. Symptom that will lead to this NPE: Drag Shortcut from homescreen to somewhere else. Old icon will not get removed while dragging. This should also be fixed! Change-Id: I5b5070c93077e69f0f63a26d337fb9aee83ec6d2 --- src/com/android/launcher3/Workspace.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/com/android/launcher3/Workspace.java') diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 83074aeda..376ebb483 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2878,7 +2878,9 @@ public class Workspace extends SmoothPagedView final ItemInfo info = (ItemInfo) cell.getTag(); if (hasMovedLayouts) { // Reparent the view - getParentCellLayoutForView(cell).removeView(cell); + CellLayout parent = getParentCellLayoutForView(cell); + if (parent != null) + parent.removeView(cell); addInScreen(cell, container, screenId, mTargetCell[0], mTargetCell[1], info.spanX, info.spanY); } -- cgit v1.2.3