From d3063c811781a21e069bb1ddd52f74a276f73292 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Tue, 7 Jul 2020 16:01:32 +0200 Subject: [PATCH] Make sure not to launch the FX app more than once. --- .../org/cryptomator/ui/launcher/FxApplicationStarter.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/launcher/FxApplicationStarter.java b/main/ui/src/main/java/org/cryptomator/ui/launcher/FxApplicationStarter.java index 41419caa4..7bdd46ce2 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/launcher/FxApplicationStarter.java +++ b/main/ui/src/main/java/org/cryptomator/ui/launcher/FxApplicationStarter.java @@ -11,6 +11,7 @@ import javax.inject.Singleton; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.ExecutorService; +import java.util.concurrent.atomic.AtomicBoolean; @Singleton public class FxApplicationStarter { @@ -19,17 +20,19 @@ public class FxApplicationStarter { private final FxApplicationComponent.Builder fxAppComponent; private final ExecutorService executor; + private final AtomicBoolean started; private final CompletableFuture future; @Inject public FxApplicationStarter(FxApplicationComponent.Builder fxAppComponent, ExecutorService executor) { this.fxAppComponent = fxAppComponent; this.executor = executor; + this.started = new AtomicBoolean(); this.future = new CompletableFuture<>(); } - public synchronized CompletionStage get(boolean hasTrayIcon) { - if (!future.isDone()) { + public CompletionStage get(boolean hasTrayIcon) { + if (!started.getAndSet(true)) { start(hasTrayIcon); } return future;