瀏覽代碼

Added runLater to implementation of ErrorComponent#showErrorScene()

JaniruTEC 4 年之前
父節點
當前提交
3a5937b35f

+ 9 - 0
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();

+ 1 - 3
main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java

@@ -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) {