mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-30 00:56:56 +13:00
Make window init error handling more robust
This commit is contained in:
parent
4542225c3f
commit
5aa1c35eb1
2 changed files with 21 additions and 11 deletions
|
@ -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(() -> {
|
||||||
|
try {
|
||||||
Alert a = supplier.get();
|
Alert a = supplier.get();
|
||||||
c.accept(a);
|
c.accept(a);
|
||||||
result.set(a.showAndWait());
|
result.set(a.showAndWait());
|
||||||
|
} catch (Throwable t) {
|
||||||
|
result.set(Optional.empty());
|
||||||
|
} finally {
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
latch.await();
|
latch.await();
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue