OSDN Git Service

Fix NPE when setting new LayoutTransition
authorChet Haase <chet@google.com>
Tue, 27 Aug 2013 19:22:29 +0000 (12:22 -0700)
committerChet Haase <chet@google.com>
Tue, 27 Aug 2013 19:22:29 +0000 (12:22 -0700)
commitfee6f2b3d30fe222486a70a773683e21d9dd12bf
tree993ed77ab282d3883c2b32935e968872cdb7359d
parentf8388885e49a0a0fa71f9a90301bd90a349cb1dd
Fix NPE when setting new LayoutTransition

ViewGroup.setLayoutTransition() has logic to cancel a previously-running
transition and remove the ViewGroup's listener from that transition. However,
it is possible for the transition to be set to null on the ViewGroup on the
cancel() call, making the next call to remove the listener crash with an NPE.

The fix is to use a temporary variable to hold the old reference and
not depend on the class instance variable remaining valid/non-null across
the call to cancel().

Issue #10488932 Hangout NPE in ViewGroup.setLayoutTransition on initiating a new conversation
Issue #10509201 ViewGroup.setLayoutTransition(null) causes crash when being called in LayoutTransition.TransitionListener.endTransition()

Change-Id: I7c181b79e6601024c93a8dc246d32b751f78b216
core/java/android/view/ViewGroup.java