Skip to content

Commit

Permalink
fix: Suppress JVM error when closing application with shown dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
teletha committed Nov 9, 2023
1 parent 7e2662b commit 7d16bda
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/viewtify/ViewtyDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,18 @@ private <D extends Dialog<R>, R> D initialize(D dialog) {
*/
private <V> Variable<V> showAndTell(Dialog<V> dialog, Supplier<V> defaultValue) {
try {
// TODO The JVM throws an error when exiting an application with a dialog open. Even if
// I try to close the dialog before exiting the application, it throws an exception due
// to a NestedLoop problem. I have no idea how to deal with this, so I just ignore the
// error. This is a wall of grief.
disposer.add(() -> {
try {
dialog.close();
} catch (IllegalArgumentException e) {
// wall of grief
}
});

return Variable.of(dialog.showAndWait().orElseGet(defaultValue));
} finally {
disposer.dispose();
Expand Down

0 comments on commit 7d16bda

Please sign in to comment.