Skip to content

Commit

Permalink
Fix NullPointerException when preference directory is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Darsen committed Jun 9, 2019
1 parent 91839fe commit 1243762
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/ch/picturex/controller/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
setSearchBarListener(globingTextField);

//alla partenza se il programma è già stato usato fa partire tutto dall'ultimo path
if (getLastDirectoryPreferences() != null && getLastDirectoryPreferences().canRead()) {
if (getLastDirectoryPreferences() != null) {
chosenDirectory = getLastDirectoryPreferences();
directoryChosenAction();
} else {
Expand Down Expand Up @@ -328,7 +328,10 @@ private File getLastDirectoryPreferences() {
Preferences preference = Preferences.userNodeForPackage(Model.class);
String filePath = preference.get("directory", null);
if (filePath != null) {
return new File(filePath);
File file = new File(filePath);
if (file.canRead()) {
return file;
}
}
return null;
}
Expand Down

0 comments on commit 1243762

Please sign in to comment.