summaryrefslogtreecommitdiffstats
path: root/core/java/android/view
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-08-17 20:17:30 -0700
committerRomain Guy <romainguy@android.com>2009-08-18 10:16:41 -0700
commit15df6703f8bf3255eb7ba5c27e3518f60adc83f1 (patch)
tree2b1a3c484048a1afaf69ef3cac7596a2cbff920e /core/java/android/view
parent6a2d513a4ad116fc5405d4d4f1f6fdb692bdefbc (diff)
downloadframeworks_base-15df6703f8bf3255eb7ba5c27e3518f60adc83f1.zip
frameworks_base-15df6703f8bf3255eb7ba5c27e3518f60adc83f1.tar.gz
frameworks_base-15df6703f8bf3255eb7ba5c27e3518f60adc83f1.tar.bz2
Fix potential leak in ViewRoot.
The way View.post() is handled can cause potential leaks in ViewRoot. For instance, if a View calls post(Runnable) just after being detached from the window (in an onClickListener for instance,) it will enqueue a Runnable in ViewRoot.RunQueue. Unfortunately the RunQueue is emptied only on the very first layout of the ViewRoot. This change prevents the leak by rxecuting the enqueued Runnables on every layout request The latter did not happen before and to keep views in a correct state I think it is necessary to always ensure we run the Runnables sent via View.post().
Diffstat (limited to 'core/java/android/view')
-rw-r--r--core/java/android/view/ViewRoot.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 3b78060..fe3f47f 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -686,7 +686,6 @@ public final class ViewRoot extends Handler implements ViewParent,
attachInfo.mKeepScreenOn = false;
viewVisibilityChanged = false;
host.dispatchAttachedToWindow(attachInfo, 0);
- getRunQueue().executeActions(attachInfo.mHandler);
//Log.i(TAG, "Screen on initialized: " + attachInfo.mKeepScreenOn);
} else {
@@ -719,6 +718,10 @@ public final class ViewRoot extends Handler implements ViewParent,
boolean insetsChanged = false;
if (mLayoutRequested) {
+ // Execute enqueued actions on every layout in case a view that was detached
+ // enqueued an action after being detached
+ getRunQueue().executeActions(attachInfo.mHandler);
+
if (mFirst) {
host.fitSystemWindows(mAttachInfo.mContentInsets);
// make sure touch mode code executes by setting cached value
@@ -3142,7 +3145,7 @@ public final class ViewRoot extends Handler implements ViewParent,
handler.postDelayed(handlerAction.action, handlerAction.delay);
}
- mActions.clear();
+ actions.clear();
}
}
@@ -3156,7 +3159,6 @@ public final class ViewRoot extends Handler implements ViewParent,
if (o == null || getClass() != o.getClass()) return false;
HandlerAction that = (HandlerAction) o;
-
return !(action != null ? !action.equals(that.action) : that.action != null);
}