Merge "Make sure to cleanup views that couldn't be added" into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2022-07-12 20:42:06 +00:00
committed by Android (Google) Code Review

View File

@@ -404,9 +404,10 @@ public final class WindowManagerGlobal {
try {
root.setView(view, wparams, panelParentView, userId);
} catch (RuntimeException e) {
final int viewIndex = findViewLocked(view, false);
// BadTokenException or InvalidDisplayException, clean up.
if (index >= 0) {
removeViewLocked(index, true);
if (viewIndex >= 0) {
removeViewLocked(viewIndex, true);
}
throw e;
}