Bug fixes

This commit is contained in:
crschnick 2023-10-25 20:44:13 +00:00
parent 8b1754ca4c
commit 4df64b5e9e
3 changed files with 7 additions and 30 deletions

View file

@ -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());

View file

@ -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<Throwable> 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();

View file

@ -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);
}
}