mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-19 19:21:27 +00:00
Make sure not to launch the FX app more than once.
This commit is contained in:
@@ -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<FxApplication> 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<FxApplication> get(boolean hasTrayIcon) {
|
||||
if (!future.isDone()) {
|
||||
public CompletionStage<FxApplication> get(boolean hasTrayIcon) {
|
||||
if (!started.getAndSet(true)) {
|
||||
start(hasTrayIcon);
|
||||
}
|
||||
return future;
|
||||
|
||||
Reference in New Issue
Block a user