From 6e6db61809a9cf31f110fb53be09b43cfb9f14de Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Mon, 26 Sep 2011 13:49:33 -0700 Subject: [PATCH] Fix display list issue that was crashing an external app. The app was removing a View whilst in its onDraw() method. This meant that we asked it for its display list and it invalidated that display list (by removing itself) before it returned from onDraw(). We later attempted to draw that invalid display list into its parent nad died in native code. The fix is to check the state of the display list after the call to getDisplayList() and to avoid doing further work with it if it's invalid. Change-Id: I14a342b4fe79c8dce2626ff61237b447040e7f42 --- core/java/android/view/ViewGroup.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index a29cf13f4ef86..28e44856f0e8b 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -2824,6 +2824,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (hasDisplayList) { displayList = child.getDisplayList(); + if (!displayList.isValid()) { + // Uncommon, but possible. If a view is removed from the hierarchy during the call + // to getDisplayList(), the display list will be marked invalid and we should not + // try to use it again. + displayList = null; + hasDisplayList = false; + } } if (hasNoCache) {