OSDN Git Service

DO NOT MERGE: Don't crash when we get a drag-ended after being detached
authorChristopher Tate <ctate@google.com>
Mon, 4 Mar 2013 20:57:23 +0000 (12:57 -0800)
committerChristopher Tate <ctate@google.com>
Mon, 4 Mar 2013 22:02:29 +0000 (14:02 -0800)
Removing view groups during a drag would cause an NPE here.  The
child views will still get the drag-ended event as expected.

(Cherrypicked from downstream)

Bug 8298439

Change-Id: Ic14cbf9fdc305b91c1627f6882a45d34ee1c34ae

core/java/android/view/ViewGroup.java

index 5105fda..df07f3c 100644 (file)
@@ -1152,8 +1152,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
                 }
 
                 mDragNotifiedChildren.clear();
-                mCurrentDrag.recycle();
-                mCurrentDrag = null;
+                if (mCurrentDrag != null) {
+                    mCurrentDrag.recycle();
+                    mCurrentDrag = null;
+                }
             }
 
             // We consider drag-ended to have been handled if one of our children