Skip to content

Commit 37f70b5

Browse files
committed
Fix NullPointerException when settings directory does not yet exist
1 parent e8babc5 commit 37f70b5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/java/de/thomas_oster/visicut/managers/PreferencesManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ public void savePreferences(Preferences pref) throws FileNotFoundException, IOEx
333333

334334
public void savePreferences() throws FileNotFoundException, IOException
335335
{
336+
if (preferences == null)
337+
{
338+
preferences = new Preferences();
339+
}
336340
File target = this.getPreferencesPath();
337341
File settingsDir = target.getParentFile();
338342
if (settingsDir.isDirectory() || settingsDir.mkdirs())
@@ -343,7 +347,7 @@ public void savePreferences() throws FileNotFoundException, IOException
343347
this.savePreferences(anonymizedPreferences, target);
344348

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

0 commit comments

Comments
 (0)