diff options
author | Romain Guy <romainguy@google.com> | 2012-03-15 15:56:11 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2012-03-15 15:56:11 -0700 |
commit | bc7616eae90002879f1d82d5e99dea7d1152b742 (patch) | |
tree | 05d7e677584534464f80e74852fa35549caaf056 | |
parent | acdd4b9c4b03bc6660274ab878731383adb5bca5 (diff) | |
download | frameworks_base-bc7616eae90002879f1d82d5e99dea7d1152b742.zip frameworks_base-bc7616eae90002879f1d82d5e99dea7d1152b742.tar.gz frameworks_base-bc7616eae90002879f1d82d5e99dea7d1152b742.tar.bz2 |
Postpone DisplayList recycling when detached from window
This was causing a crash in apps that remove views during a draw pass.
Change-Id: I1c4621639fe920291b2c6fb7bfd17a69101a1329
-rw-r--r-- | core/java/android/view/DisplayList.java | 16 | ||||
-rw-r--r-- | core/java/android/view/View.java | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/core/java/android/view/DisplayList.java b/core/java/android/view/DisplayList.java index a50f09f..06927a7 100644 --- a/core/java/android/view/DisplayList.java +++ b/core/java/android/view/DisplayList.java @@ -16,6 +16,8 @@ package android.view; +import android.os.Handler; + /** * A display lists records a series of graphics related operation and can replay * them later. Display lists are usually built by recording operations on a @@ -26,6 +28,13 @@ package android.view; * @hide */ public abstract class DisplayList { + private final Runnable mInvalidate = new Runnable() { + @Override + public void run() { + invalidate(); + } + }; + /** * Flag used when calling * {@link HardwareCanvas#drawDisplayList(DisplayList, int, int, android.graphics.Rect, int)}. @@ -57,6 +66,13 @@ public abstract class DisplayList { public abstract void invalidate(); /** + * Posts a call to {@link #invalidate()} in the specified handler. + */ + final void postInvalidate(Handler handler) { + handler.post(mInvalidate); + } + + /** * Returns whether the display list is currently usable. If this returns false, * the display list should be re-recorded prior to replaying it. * diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 1edcff6..1433ee0 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -9975,7 +9975,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal destroyLayer(); if (mDisplayList != null) { - mDisplayList.invalidate(); + mDisplayList.postInvalidate(mAttachInfo.mHandler); } if (mAttachInfo != null) { |