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

Commit f143ace3 authored by James Cook's avatar James Cook
Browse files

Fix crash in UndoManager after parceling TextView

UndoOwner maintains a manual reference count of the number of undo operations
it is associated with, but this count is not restored (and hence becomes zero)
when UndoManager is parceled and unparceled. This can cause the count to
underflow on subsequent text editing.

A test for this will land separately in CTS.

Bug: 19568283
Change-Id: Ic50890828db9679c7cef805388957d66dc75422d
parent f63a665f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@ public class UndoManager {
            owner.mSavedIdx = mNextSavedIdx;
            out.writeInt(owner.mSavedIdx);
            out.writeString(owner.mTag);
            out.writeInt(owner.mOpCount);
            mNextSavedIdx++;
        }
    }
@@ -200,7 +201,9 @@ public class UndoManager {
        UndoOwner owner = mStateOwners[idx];
        if (owner == null) {
            String tag = in.readString();
            int opCount = in.readInt();
            owner = new UndoOwner(tag, this);
            owner.mOpCount = opCount;
            mStateOwners[idx] = owner;
            mOwners.put(tag, owner);
        }
+11 −0
Original line number Diff line number Diff line
@@ -61,4 +61,15 @@ public class UndoOwner {
    public Object getData() {
        return mData;
    }

    @Override
    public String toString() {
        return "UndoOwner:[mTag=" + mTag +
                " mManager=" + mManager +
                " mData=" + mData +
                " mData=" + mData +
                " mOpCount=" + mOpCount +
                " mStateSeq=" + mStateSeq +
                " mSavedIdx=" + mSavedIdx + "]";
    }
}