From: Svjatoslav Agejenko Date: Sun, 20 Nov 2016 20:36:25 +0000 (+0200) Subject: null pointer bug fix X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=44c72c4cfd1d47604ac6f6cc9b43992fead66fd6;p=instantlauncher.git null pointer bug fix --- diff --git a/src/main/java/eu/svjatoslav/instantlauncher/configuration/ConfigurationManager.java b/src/main/java/eu/svjatoslav/instantlauncher/configuration/ConfigurationManager.java index 4a06d06..8e13042 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/configuration/ConfigurationManager.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/configuration/ConfigurationManager.java @@ -28,18 +28,15 @@ public class ConfigurationManager { final File propertiesFile = getPropertiesFile(); if (!propertiesFile.exists()) { initDefaultConfiguration(); - saveConfigFile(); } else loadConfigFile(propertiesFile); } - private void loadConfigFile(File propertiesFile) throws FileNotFoundException, com.esotericsoftware.yamlbeans.YamlException { + private void loadConfigFile(File propertiesFile) throws IOException { YamlReader reader = new YamlReader(new FileReader(propertiesFile)); configuration = reader.read(Configuration.class); - if (configuration == null) { - configuration = new Configuration(); - configuration.fileAssociations = new HashSet<>(); - } + if (configuration == null) + initDefaultConfiguration(); } private void saveConfigFile() throws IOException { @@ -53,7 +50,10 @@ public class ConfigurationManager { configuration.fileAssociations.add(association); } - private void initDefaultConfiguration() { + private void initDefaultConfiguration() throws IOException { + configuration = new Configuration(); + configuration.fileAssociations = new HashSet<>(); + configuration.navigationRootPath = System.getProperty("user.home") + "/"; configuration.directoryOpenCommand = "nautilus -w {file}"; @@ -65,5 +65,7 @@ public class ConfigurationManager { registerFileAssociation(".*\\.avi$", "vlc {file}"); registerFileAssociation(".*\\.mp4$", "vlc {file}"); registerFileAssociation(".*\\.mkv$", "vlc {file}"); + + saveConfigFile(); } }