Make window init error handling more robust

This commit is contained in:
crschnick 2024-01-02 15:26:53 +00:00
parent 4542225c3f
commit 5aa1c35eb1
2 changed files with 21 additions and 11 deletions

View file

@ -142,10 +142,15 @@ public class AppWindowHelper {
if (!Platform.isFxApplicationThread()) {
CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(() -> {
Alert a = supplier.get();
c.accept(a);
result.set(a.showAndWait());
latch.countDown();
try {
Alert a = supplier.get();
c.accept(a);
result.set(a.showAndWait());
} catch (Throwable t) {
result.set(Optional.empty());
} finally {
latch.countDown();
}
});
try {
latch.await();

View file

@ -106,13 +106,18 @@ public class ErrorHandlerComp extends SimpleComp {
Platform.runLater(() -> {
if (!showing.get()) {
showing.set(true);
var window = AppWindowHelper.sideWindow(
AppI18n.get("errorHandler"),
w -> {
return setUpComp(event, w, finishLatch);
},
true,
null);
Stage window = null;
try {
window = AppWindowHelper.sideWindow(AppI18n.get("errorHandler"), w -> {
return setUpComp(event, w, finishLatch);
}, true, null);
} catch (Throwable t) {
showLatch.countDown();
finishLatch.countDown();
showing.set(false);
t.printStackTrace();
return;
}
// An exception is thrown when show and wait is called
// within an animation or layout processing task, so use show
try {