Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15177899 authored by Vadim Tryshev's avatar Vadim Tryshev
Browse files

Fixing crash in D&D due to race conditions during drag end.

*** MERGING TO MASTER ***

Drag-end event processing for a child view can remove the GroupView,
Which will synchronously call dispatchDetachedFromWindow(), which will
null mChildrenInterestedInDrag.
This causes a crash when trying to clear the map.

Fixing by introducing a local variable.

Bug: 25433279
Change-Id: I2ef88f7f97935dbafda54634831fbbff747b8f2e
(cherry picked from commit 2e2f1066ad89110365cdb504bf6568569d94da58)
parent 20e082c7
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -1419,8 +1419,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager

        case DragEvent.ACTION_DRAG_ENDED: {
            // Release the bookkeeping now that the drag lifecycle has ended
            if (mChildrenInterestedInDrag != null) {
                for (View child : mChildrenInterestedInDrag) {
            final HashSet<View> childrenInterestedInDrag = mChildrenInterestedInDrag;
            if (childrenInterestedInDrag != null) {
                for (View child : childrenInterestedInDrag) {
                    // If a child was interested in the ongoing drag, it's told that it's over
                    if (child.dispatchDragEvent(event)) {
                        retval = true;
@@ -1428,13 +1429,12 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
                    child.mPrivateFlags2 &= ~View.DRAG_MASK;
                    child.refreshDrawableState();
                }

                mChildrenInterestedInDrag.clear();
                childrenInterestedInDrag.clear();
            }
            if (mCurrentDragStartEvent != null) {
                mCurrentDragStartEvent.recycle();
                mCurrentDragStartEvent = null;
            }
            }

            if (mIsInterestedInDrag) {
                if (super.dispatchDragEvent(event)) {