From df74ec5e4ce6804727e79c4f6ca10a197da12e06 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 29 Dec 2014 11:47:26 +0000 Subject: [PATCH] * fix potential issues with previously accessed folders not being available anymore --- source/net/filebot/UserFiles.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/net/filebot/UserFiles.java b/source/net/filebot/UserFiles.java index d9503951..5836d4f2 100644 --- a/source/net/filebot/UserFiles.java +++ b/source/net/filebot/UserFiles.java @@ -105,9 +105,9 @@ public class UserFiles { chooser.setFileSelectionMode(folderMode && filter == null ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_AND_DIRECTORIES); if (defaultFile != null) { - if (defaultFile.exists()) { + if (defaultFile.isFile()) { chooser.setSelectedFile(defaultFile); - } else if (defaultFile.getParentFile().exists()) { + } else if (defaultFile.getParentFile() != null && defaultFile.getParentFile().isDirectory()) { chooser.setCurrentDirectory(defaultFile.getParentFile()); } } @@ -171,7 +171,7 @@ public class UserFiles { fileDialog.setTitle(title); fileDialog.setMultipleMode(false); if (defaultFile != null) { - if (defaultFile.getParentFile() != null) { + if (defaultFile.getParentFile() != null && defaultFile.getParentFile().isDirectory()) { fileDialog.setDirectory(defaultFile.getParentFile().getPath()); } fileDialog.setFile(defaultFile.getName()); @@ -248,7 +248,7 @@ public class UserFiles { if (folderMode) { javafx.stage.DirectoryChooser directoryChooser = new javafx.stage.DirectoryChooser(); directoryChooser.setTitle(title); - if (defaultFile != null) { + if (defaultFile != null && defaultFile.isDirectory()) { directoryChooser.setInitialDirectory(defaultFile); } @@ -301,7 +301,7 @@ public class UserFiles { fileChooser.setTitle(title); if (defaultFile != null) { - if (defaultFile.getParentFile() != null) { + if (defaultFile.getParentFile() != null && defaultFile.getParentFile().isDirectory()) { fileChooser.setInitialDirectory(defaultFile.getParentFile()); } fileChooser.setInitialFileName(defaultFile.getName());