diff --git a/src/app/file_selector.cpp b/src/app/file_selector.cpp index 21adf712e..31ea9ebcd 100644 --- a/src/app/file_selector.cpp +++ b/src/app/file_selector.cpp @@ -125,11 +125,9 @@ std::string get_initial_path_to_select_filename(const std::string& initialFilena std::string get_current_dir_for_file_selector() { std::string path = Preferences::instance().fileSelector.currentFolder(); - // If it's empty or the folder doesn't exist anymore, starts from - // the docs folder by default. - if (path.empty() || - path == "" || - !base::is_directory(path)) { + // "" is the default value for this property, to start from + // the user docs folder by default. + if (path == "") { path = base::get_user_docs_folder(); } return path; diff --git a/src/app/ui/file_selector.cpp b/src/app/ui/file_selector.cpp index 2d7151688..b7bd67cbb 100644 --- a/src/app/ui/file_selector.cpp +++ b/src/app/ui/file_selector.cpp @@ -411,10 +411,20 @@ bool FileSelector::show( fs->refresh(); // We have to find where the user should begin to browse files - std::string start_folder_path = - base::get_file_path(get_initial_path_to_select_filename(initialPath)); - IFileItem* start_folder = fs->getFileItemFromPath(start_folder_path); + std::string start_folder_path; + if (initialPath.empty()) { + start_folder_path = get_initial_path_to_select_filename(initialPath); + } + else { + start_folder_path = base::get_file_path(initialPath); + } + IFileItem* start_folder = fs->getFileItemFromPath(start_folder_path); + if (!start_folder) { + // If the directory doesn't exist anymore, get the default FS item + // (root item, or user folder). + start_folder = fs->getFileItemFromPath(std::string()); + } FILESEL_TRACE("FILESEL: Start folder '%s' (%p)\n", start_folder_path.c_str(), start_folder); {