Skip to content

Commit

Permalink
Fix importing preferences after resetting without restarting (#3065)
Browse files Browse the repository at this point in the history
* Fix importing preferences after resetting without restarting
Set default Prefs to USER_HOME instead of working dir which could not have been intialized

* add changelog entry
  • Loading branch information
Siedlerchr authored Aug 2, 2017
1 parent 5e04195 commit 63414b0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ If fetched article is already in database the ImportInspectionDialog is started
### Fixed
We fixed an issue where the fetcher for the Astrophysics Data System (ADS) added some non-bibtex data to the entry returned from the search [#3035](https://github.com/JabRef/jabref/issues/3035)
We fixed an issue where assigning an entry via drag and drop to a group caused JabRef to stop/freeze completely [#3036](https://github.com/JabRef/jabref/issues/3036)
We fixed an issue where the preferences could not be imported without a restart of JabRef [#3064](https://github.com/JabRef/jabref/issues/3064)
### Removed


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public Builder withInitialDirectory(Path directory) {
}
//The lines above work also if the dir does not exist at all!
//NULL is accepted by the filechooser as no inital path
if (!Files.exists(directory)) {
//Explicit null check, if somehow the parent is null, as Files.exists throws an NPE otherwise
if ((directory != null) && !Files.exists(directory)) {
directory = null;
}
initialDirectory = directory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ private JabRefPreferences() {
defaults.put(EXPORT_WORKING_DIRECTORY, USER_HOME);
// Remembers working directory of last import
defaults.put(IMPORT_WORKING_DIRECTORY, USER_HOME);
defaults.put(PREFS_EXPORT_PATH, WORKING_DIRECTORY);
defaults.put(PREFS_EXPORT_PATH, USER_HOME);
defaults.put(AUTO_OPEN_FORM, Boolean.TRUE);
defaults.put(BACKUP, Boolean.TRUE);
defaults.put(OPEN_LAST_EDITED, Boolean.TRUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public void testWithNullPathDirectory() {
assertEquals(Optional.ofNullable(tempFolder), fileDialogConfiguration.getInitialDirectory());
}

@Test
public void testWithNonExistingDirectoryAndParentNull() {
String tempFolder = "workingDirectory";
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.withInitialDirectory(tempFolder).build();

assertEquals(Optional.ofNullable(null), fileDialogConfiguration.getInitialDirectory());
}

@Test
public void testSingleExtension() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
Expand Down

0 comments on commit 63414b0

Please sign in to comment.