Added runLater to implementation of ErrorComponent#showErrorScene()

This commit is contained in:
JaniruTEC
2020-11-06 17:09:44 +01:00
parent 313f8b36d2
commit 3a5937b35f
2 changed files with 10 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ import dagger.BindsInstance;
import dagger.Subcomponent;
import javax.annotation.Nullable;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.stage.Stage;
@@ -16,6 +17,14 @@ public interface ErrorComponent {
Scene scene();
default void showErrorScene() {
if (Platform.isFxApplicationThread()) {
show();
} else {
Platform.runLater(this::show);
}
}
private void show() {
Stage stage = window();
stage.setScene(scene());
stage.show();

View File

@@ -209,9 +209,7 @@ public class UnlockWorkflow extends Task<Boolean> {
private void handleGenericError(Throwable e) {
LOG.error("Unlock failed for technical reasons.", e);
Platform.runLater(() -> {
errorComponent.cause(e).window(window).returnToScene(window.getScene()).build().showErrorScene();
});
errorComponent.cause(e).window(window).returnToScene(window.getScene()).build().showErrorScene();
}
private void wipePassword(char[] pw) {