diff options
| author | Chet Haase <chet@google.com> | 2011-01-27 10:30:25 -0800 |
|---|---|---|
| committer | Chet Haase <chet@google.com> | 2011-01-27 10:30:25 -0800 |
| commit | f4ac547f868db7c8a358e1f6e3d8fcebb02dbd49 (patch) | |
| tree | 3bc02f0ae034b5acba5082a8cadad237a6991981 /core/java/android/view/View.java | |
| parent | e38ba4acbe6f1536997ffb98d662fc3eff07add8 (diff) | |
Fix NPE with display lists when view not attached
There was logic in ViewGroup that assumed that an accelerated
view must always be able to get a display list for any child
that it was drawing. One situation occurred, however, that
caused a problem with this - a contacts activity was started
and not yet attached, but was being asked to render into an
accelerated canvas. We assumed that the child would have a display
list and simply called getDisplayList(). But since that call
returned null, we later deref'd the null object.
The fix is to check whether a child can have a display list
instead of assuming that it can just because the container view
is accelerated.
Change-Id: I7de62fd597ad50720c9585d621bec02e77c171df
Diffstat (limited to 'core/java/android/view/View.java')
| -rw-r--r-- | core/java/android/view/View.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index c64f5648e541..5e8f31aceef9 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -8227,6 +8227,21 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * @hide */ protected void dispatchGetDisplayList() {} + + /** + * A view that is not attached or hardware accelerated cannot create a display list. + * This method checks these conditions and returns the appropriate result. + * + * @return true if view has the ability to create a display list, false otherwise. + * + * @hide + */ + public boolean canHaveDisplayList() { + if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { + return false; + } + return true; + } /** * <p>Returns a display list that can be used to draw this view again @@ -8237,7 +8252,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * @hide */ public DisplayList getDisplayList() { - if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) { + if (!canHaveDisplayList()) { return null; } |
