Skip to content

Commit f84208f

Browse files
author
Romain Guy
committed
Prevent crash when invalidating all Views
Bug #7165793 A ViewRootImpl's root view can be null. Check for this condition to prevent an NPE invalidateWorld(). Other messages perform a similar check to properly handle the case where mView == null. Change-Id: I5bcfc41c48a469d38b21be74df2f6c715b0f9352
1 parent 1a5efec commit f84208f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/java/android/view/ViewRootImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,8 @@ void invalidate() {
832832
void invalidateWorld(View view) {
833833
view.invalidate();
834834
if (view instanceof ViewGroup) {
835-
ViewGroup parent = (ViewGroup)view;
836-
for (int i=0; i<parent.getChildCount(); i++) {
835+
ViewGroup parent = (ViewGroup) view;
836+
for (int i = 0; i < parent.getChildCount(); i++) {
837837
invalidateWorld(parent.getChildAt(i));
838838
}
839839
}
@@ -2998,7 +2998,9 @@ public void handleMessage(Message msg) {
29982998
handleDispatchDoneAnimating();
29992999
} break;
30003000
case MSG_INVALIDATE_WORLD: {
3001-
invalidateWorld(mView);
3001+
if (mView != null) {
3002+
invalidateWorld(mView);
3003+
}
30023004
} break;
30033005
}
30043006
}

0 commit comments

Comments
 (0)