Fix leak fix in ViewTreeObserver
The leak fix of the CopyOnWriteArray in ViewTreeObserver was
too aggressive, always clearing the shadow copy when it should only
have cleared it when needed. The way it works now, we will always
clear the listeners for ViewTreeObserver after the listeners
are processed.
Issue #10815924 ViewTreeObserver leak fix too aggressive
Change-Id: Iff0095d73beb38e52b0a5ae6b6378afec4458fd3
diff --git a/core/java/android/view/ViewTreeObserver.java b/core/java/android/view/ViewTreeObserver.java
index ad8b51d..f9298ea 100644
--- a/core/java/android/view/ViewTreeObserver.java
+++ b/core/java/android/view/ViewTreeObserver.java
@@ -990,10 +990,10 @@
mStart = false;
if (mDataCopy != null) {
mData = mDataCopy;
+ mAccess.mData.clear();
+ mAccess.mSize = 0;
}
mDataCopy = null;
- mAccess.mData.clear();
- mAccess.mSize = 0;
}
int size() {