mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 17:10:27 +00:00
Bug fixes
This commit is contained in:
parent
8b1754ca4c
commit
4df64b5e9e
3 changed files with 7 additions and 30 deletions
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue