Skip to content

Commit

Permalink
Catch rare RuntimeException in setRoot when waitForRender = true (#5428)
Browse files Browse the repository at this point in the history
When setRoot is called with `waitForRender=true`, check if the root view is destroyed before displaying it.
  • Loading branch information
rawrmaan authored and guyca committed Sep 5, 2019
1 parent a99e138 commit b048581
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ public void setRoot(ViewController root, Options defaultOptions, CommandListener
if (options.animations.setRoot.waitForRender.isTrue()) {
root.getView().setAlpha(0);
root.addOnAppearedListener(() -> {
root.getView().setAlpha(1);
animateSetRootAndReportSuccess(root, listener, options);
if (root.isDestroyed()) {
listener.onError("Could not set root - Waited for the view to become visible but it was destroyed");
} else {
root.getView().setAlpha(1);
animateSetRootAndReportSuccess(root, listener, options);
}
});
} else {
animateSetRootAndReportSuccess(root, listener, options);
Expand Down

0 comments on commit b048581

Please sign in to comment.