From 3a5937b35fb6bd7ba92d8adf7f2f636e7e5d1d08 Mon Sep 17 00:00:00 2001 From: JaniruTEC Date: Fri, 6 Nov 2020 17:09:44 +0100 Subject: [PATCH] Added runLater to implementation of ErrorComponent#showErrorScene() --- .../java/org/cryptomator/ui/common/ErrorComponent.java | 9 +++++++++ .../java/org/cryptomator/ui/unlock/UnlockWorkflow.java | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/common/ErrorComponent.java b/main/ui/src/main/java/org/cryptomator/ui/common/ErrorComponent.java index 6a50ee44a..285270b4c 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/common/ErrorComponent.java +++ b/main/ui/src/main/java/org/cryptomator/ui/common/ErrorComponent.java @@ -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(); diff --git a/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java b/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java index 9b95103ad..8cb7e0752 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java +++ b/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java @@ -209,9 +209,7 @@ public class UnlockWorkflow extends Task { 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) {