Browse Source

Fix errors when identity manager loads defaults in the wrong order

Output a valid identity during the build process
IdentityManager now loads the version information
tags/0.6.3m1rc1
Chris Smith 15 years ago
parent
commit
4d6630d9df

+ 6
- 0
build-versioning.xml View File

@@ -14,9 +14,15 @@
14 14
 # the build process.
15 15
 
16 16
 keysections:
17
+   identity
17 18
    version
18 19
    updater
19 20
 
21
+identity:
22
+   name=DMDirc version information
23
+   globaldefault=true
24
+   order=95000
25
+
20 26
 version:
21 27
    version=</echo>
22 28
     </target>

+ 0
- 2
src/com/dmdirc/Main.java View File

@@ -116,8 +116,6 @@ public final class Main {
116 116
         final CommandLineParser clp = new CommandLineParser(args);
117 117
         
118 118
         IdentityManager.load();
119
-        IdentityManager.getConfigIdentity().setOption("updater", "channel",
120
-                UPDATE_CHANNEL.name()); // Hack until we set it decently
121 119
 
122 120
         final PluginManager pm = PluginManager.getPluginManager();
123 121
         

+ 12
- 1
src/com/dmdirc/config/IdentityManager.java View File

@@ -33,6 +33,7 @@ import com.dmdirc.util.resourcemanager.ResourceManager;
33 33
 
34 34
 import java.io.File;
35 35
 import java.io.IOException;
36
+import java.net.URISyntaxException;
36 37
 import java.util.ArrayList;
37 38
 import java.util.Collections;
38 39
 import java.util.HashMap;
@@ -70,8 +71,9 @@ public final class IdentityManager {
70 71
     public static void load() {
71 72
         identities.clear();
72 73
         managers.clear();
73
-        
74
+
74 75
         loadDefaults();
76
+        loadVersion();
75 77
         loadUser();
76 78
         loadConfig();
77 79
         
@@ -223,6 +225,15 @@ public final class IdentityManager {
223 225
                     + file.getAbsolutePath());
224 226
         }
225 227
     }
228
+
229
+    /** Loads the version information. */
230
+    private static void loadVersion() {
231
+        try {
232
+            loadIdentity(new File(Main.class.getResource("version.config").toURI()));
233
+        } catch (URISyntaxException ex) {
234
+            Logger.appError(ErrorLevel.FATAL, "Unable to read version information", ex);
235
+        }
236
+    }
226 237
     
227 238
     /** Loads the config identity. */
228 239
     private static void loadConfig() {

+ 16
- 13
src/com/dmdirc/logger/ErrorManager.java View File

@@ -87,18 +87,11 @@ public final class ErrorManager implements Serializable, ConfigChangeListener {
87 87
 
88 88
         final ConfigManager config = IdentityManager.getGlobalConfig();
89 89
 
90
-        try {
91
-            sendReports = config.getOptionBool("general", "submitErrors")
92
-                    && !config.getOptionBool("temp", "noerrorreporting");
93
-            logReports = config.getOptionBool("general", "logerrors");
94
-        } catch (IllegalArgumentException ex) {
95
-            sendReports = false;
96
-            logReports = true;
97
-        }
98
-
99 90
         config.addChangeListener("general", "logerrors", this);
100 91
         config.addChangeListener("general", "submitErrors", this);
101 92
         config.addChangeListener("temp", "noerrorreporting", this);
93
+
94
+        updateSettings();
102 95
     }
103 96
 
104 97
     /**
@@ -448,11 +441,21 @@ public final class ErrorManager implements Serializable, ConfigChangeListener {
448 441
     /** {@inheritDoc} */
449 442
     @Override
450 443
     public void configChanged(final String domain, final String key) {
444
+        updateSettings();
445
+    }
446
+
447
+    /** Updates the settings used by this error manager. */
448
+    protected void updateSettings() {
451 449
         final ConfigManager config = IdentityManager.getGlobalConfig();
452
-        
453
-        sendReports = config.getOptionBool("general", "submitErrors")
454
-                && !config.getOptionBool("temp", "noerrorreporting");
455
-        logReports = config.getOptionBool("general", "logerrors");
450
+
451
+        try {
452
+            sendReports = config.getOptionBool("general", "submitErrors")
453
+                    && !config.getOptionBool("temp", "noerrorreporting");
454
+            logReports = config.getOptionBool("general", "logerrors");
455
+        } catch (IllegalArgumentException ex) {
456
+            sendReports = false;
457
+            logReports = true;
458
+        }
456 459
     }
457 460
 
458 461
 }

Loading…
Cancel
Save