From 37309445b1c212936e405dea0565911e739366f5 Mon Sep 17 00:00:00 2001 From: argospam <20099668+argospam@users.noreply.github.com> Date: Sun, 25 Feb 2018 20:45:51 -0800 Subject: [PATCH] Checks directory exists before setInitialDirectory Added a little defensive coding to prevent error: Folder parameter must be a valid folder. --- gui/src/main/java/io/bisq/gui/util/GUIUtil.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gui/src/main/java/io/bisq/gui/util/GUIUtil.java b/gui/src/main/java/io/bisq/gui/util/GUIUtil.java index 09abbecd1e..ba13d0b3e6 100644 --- a/gui/src/main/java/io/bisq/gui/util/GUIUtil.java +++ b/gui/src/main/java/io/bisq/gui/util/GUIUtil.java @@ -139,7 +139,10 @@ public class GUIUtil { public static void importAccounts(User user, String fileName, Preferences preferences, Stage stage, PersistenceProtoResolver persistenceProtoResolver) { FileChooser fileChooser = new FileChooser(); - fileChooser.setInitialDirectory(new File(preferences.getDirectoryChooserPath())); + File initDir = new File(preferences.getDirectoryChooserPath()); + if (initDir.isDirectory()) { + fileChooser.setInitialDirectory(initDir); + } fileChooser.setTitle(Res.get("guiUtil.accountExport.selectPath", fileName)); File file = fileChooser.showOpenDialog(stage.getOwner()); if (file != null) { @@ -202,7 +205,10 @@ public class GUIUtil { public static String getDirectoryFromChooser(Preferences preferences, Stage stage) { DirectoryChooser directoryChooser = new DirectoryChooser(); - directoryChooser.setInitialDirectory(new File(preferences.getDirectoryChooserPath())); + File initDir = new File(preferences.getDirectoryChooserPath()); + if (initDir.isDirectory()) { + directoryChooser.setInitialDirectory(initDir); + } directoryChooser.setTitle(Res.get("guiUtil.accountExport.selectExportPath")); File dir = directoryChooser.showDialog(stage); if (dir != null) {