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()) { if (!Platform.isFxApplicationThread()) {
CountDownLatch latch = new CountDownLatch(1); CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(() -> { Platform.runLater(() -> {
Alert a = supplier.get(); try {
c.accept(a); Alert a = supplier.get();
result.set(a.showAndWait()); c.accept(a);
latch.countDown(); result.set(a.showAndWait());
} catch (Throwable t) {
result.set(Optional.empty());
} finally {
latch.countDown();
}
}); });
try { try {
latch.await(); latch.await();

View file

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