diff --git a/src/main/java/net/rptools/maptool/client/AppActions.java b/src/main/java/net/rptools/maptool/client/AppActions.java index a61ba52407..76a900bd47 100644 --- a/src/main/java/net/rptools/maptool/client/AppActions.java +++ b/src/main/java/net/rptools/maptool/client/AppActions.java @@ -2848,27 +2848,28 @@ protected void executeAction() { chooser.setSelectedFile(new File(zr.getZone().getName())); boolean tryAgain = true; while (tryAgain) { - if (chooser.showSaveDialog(MapTool.getFrame()) == JFileChooser.APPROVE_OPTION) { - File mapFile = chooser.getSelectedFile(); - var installDir = AppUtil.getInstallDirectory().toAbsolutePath(); - var saveDir = chooser.getSelectedFile().toPath().getParent().toAbsolutePath(); - if (saveDir.startsWith(installDir)) { - MapTool.showWarning("msg.warning.saveMapToInstallDir"); - } else { - tryAgain = false; - try { - mapFile = getFileWithExtension(mapFile, AppConstants.MAP_FILE_EXTENSION); - if (mapFile.exists()) { - if (!MapTool.confirm("msg.confirm.fileExists")) { - return; - } + if (chooser.showSaveDialog(MapTool.getFrame()) != JFileChooser.APPROVE_OPTION) { + break; + } + File mapFile = chooser.getSelectedFile(); + var installDir = AppUtil.getInstallDirectory().toAbsolutePath(); + var saveDir = chooser.getSelectedFile().toPath().getParent().toAbsolutePath(); + if (saveDir.startsWith(installDir)) { + MapTool.showWarning("msg.warning.saveMapToInstallDir"); + } else { + tryAgain = false; + try { + mapFile = getFileWithExtension(mapFile, AppConstants.MAP_FILE_EXTENSION); + if (mapFile.exists()) { + if (!MapTool.confirm("msg.confirm.fileExists")) { + return; } - PersistenceUtil.saveMap(zr.getZone(), mapFile); - AppPreferences.setSaveMapDir(mapFile.getParentFile()); - MapTool.showInformation("msg.info.mapSaved"); - } catch (IOException ioe) { - MapTool.showError("msg.error.failedSaveMap", ioe); } + PersistenceUtil.saveMap(zr.getZone(), mapFile); + AppPreferences.setSaveMapDir(mapFile.getParentFile()); + MapTool.showInformation("msg.info.mapSaved"); + } catch (IOException ioe) { + MapTool.showError("msg.error.failedSaveMap", ioe); } } }