Skip to content

Commit

Permalink
UncaughtExceptionHandler: try to save a copy of the current profile t…
Browse files Browse the repository at this point in the history
…o the TEMP folder if there are unsaved changes
  • Loading branch information
bwRavencl committed Oct 13, 2024
1 parent ae4688c commit e6b1429
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/de/bwravencl/controllerbuddy/gui/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,20 @@ public static void main(final String[] args) {
GuiUtils.showMessageDialog(main, main.frame, panel, strings.getString("ERROR_DIALOG_TITLE"),
JOptionPane.ERROR_MESSAGE);

if (main.unsavedChanges) {
try {
final var filename = main.currentFile != null ? main.currentFile.getName()
: "unnamed_profile";
final var file = new File(System.getProperty("java.io.tmpdir") + File.separator + filename);

if (!file.exists()) {
main.saveProfile(file, false);
}
} catch (final Throwable t) {
log.log(Level.SEVERE, t.getMessage(), t);
}
}

terminate(1);
});
} else {
Expand Down

0 comments on commit e6b1429

Please sign in to comment.