Skip to content

Commit

Permalink
Fix NullPointerException when settings directory does not yet exist
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmax committed Feb 8, 2024
1 parent e8babc5 commit 37f70b5
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ public void savePreferences(Preferences pref) throws FileNotFoundException, IOEx

public void savePreferences() throws FileNotFoundException, IOException
{
if (preferences == null)
{
preferences = new Preferences();
}
File target = this.getPreferencesPath();
File settingsDir = target.getParentFile();
if (settingsDir.isDirectory() || settingsDir.mkdirs())
Expand All @@ -343,7 +347,7 @@ public void savePreferences() throws FileNotFoundException, IOException
this.savePreferences(anonymizedPreferences, target);

// save full preferences file (settings.private.xml), including sensitive information (e.g., recent files)
// Note that this must be after saving the first file so that the modification date is newer.
// Note that this must be after saving the first file so that the modification date is newer (or same).
this.savePreferences(preferences, getPrivatePreferencesPath());
}
else
Expand Down

0 comments on commit 37f70b5

Please sign in to comment.