From 4df64b5e9eb050ef2b929b2d24b5b8127cef6eca Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 25 Oct 2023 20:44:13 +0000 Subject: [PATCH] Bug fixes --- .../java/io/xpipe/app/core/mode/BaseMode.java | 3 ++ .../xpipe/app/issue/GuiErrorHandlerBase.java | 33 ++----------------- .../java/io/xpipe/app/util/PlatformState.java | 1 + 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java index 21c9d84f6..edf743b51 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java @@ -32,6 +32,9 @@ public class BaseMode extends OperationMode { return; } + // For debugging + // if (true) throw new IllegalStateException(); + TrackEvent.info("mode", "Initializing base mode components ..."); AppExtensionManager.init(true); JacksonMapper.initModularized(AppExtensionManager.getInstance().getExtendedLayer()); diff --git a/app/src/main/java/io/xpipe/app/issue/GuiErrorHandlerBase.java b/app/src/main/java/io/xpipe/app/issue/GuiErrorHandlerBase.java index e618a3942..c2cfb4c84 100644 --- a/app/src/main/java/io/xpipe/app/issue/GuiErrorHandlerBase.java +++ b/app/src/main/java/io/xpipe/app/issue/GuiErrorHandlerBase.java @@ -2,45 +2,18 @@ package io.xpipe.app.issue; import io.xpipe.app.core.*; import io.xpipe.app.util.PlatformState; -import javafx.application.Platform; -import java.util.concurrent.CountDownLatch; import java.util.function.Consumer; public class GuiErrorHandlerBase { protected boolean startupGui(Consumer onFail) { - if (PlatformState.getCurrent() == PlatformState.EXITED) { + var ex = PlatformState.initPlatform(); + if (ex.isPresent()) { + onFail.accept(ex.get()); return false; } - if (PlatformState.getCurrent() == PlatformState.NOT_INITIALIZED) { - try { - CountDownLatch latch = new CountDownLatch(1); - Platform.setImplicitExit(false); - Platform.startup(latch::countDown); - try { - latch.await(); - PlatformState.setCurrent(PlatformState.RUNNING); - } catch (InterruptedException ignored) { - } - } catch (Throwable r) { - // Check if we already exited - if ("Platform.exit has been called".equals(r.getMessage())) { - PlatformState.setCurrent(PlatformState.EXITED); - return false; - } - - if ("Toolkit already initialized".equals(r.getMessage())) { - PlatformState.setCurrent(PlatformState.RUNNING); - } else { - // Platform initialization has failed in this case - onFail.accept(r); - return false; - } - } - } - try { AppProperties.init(); AppState.init(); diff --git a/app/src/main/java/io/xpipe/app/util/PlatformState.java b/app/src/main/java/io/xpipe/app/util/PlatformState.java index 96bf90ed4..11edd7dea 100644 --- a/app/src/main/java/io/xpipe/app/util/PlatformState.java +++ b/app/src/main/java/io/xpipe/app/util/PlatformState.java @@ -91,6 +91,7 @@ public enum PlatformState { // Platform initialization has failed in this case PLATFORM_LOADED = false; PlatformState.setCurrent(PlatformState.EXITED); + TrackEvent.error(t.getMessage()); return Optional.of(t); } }