Provide synchronization to setview to avoid NPE
If setView() will be called from two different threads then mView property of a View object may have inconsistent value. For instance, setView() may set mView to null causing NullPointerException. Synchronize root.setView() as well to avoid this. Change-Id: I5f9cf47ece5d4aca575bd8644ecfcee0ed43d843
This commit is contained in:
committed by
Shibin George
parent
2309b98b25
commit
f7abcda5f2
@@ -335,20 +335,17 @@ public final class WindowManagerGlobal {
|
||||
mViews.add(view);
|
||||
mRoots.add(root);
|
||||
mParams.add(wparams);
|
||||
}
|
||||
|
||||
// do this last because it fires off messages to start doing things
|
||||
try {
|
||||
root.setView(view, wparams, panelParentView);
|
||||
} catch (RuntimeException e) {
|
||||
// BadTokenException or InvalidDisplayException, clean up.
|
||||
synchronized (mLock) {
|
||||
final int index = findViewLocked(view, false);
|
||||
// do this last because it fires off messages to start doing things
|
||||
try {
|
||||
root.setView(view, wparams, panelParentView);
|
||||
} catch (RuntimeException e) {
|
||||
// BadTokenException or InvalidDisplayException, clean up.
|
||||
if (index >= 0) {
|
||||
removeViewLocked(index, true);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user