File tree Expand file tree Collapse file tree 2 files changed +19
-14
lines changed Expand file tree Collapse file tree 2 files changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -139,8 +139,20 @@ static public void main(String args[]) throws Exception {
139
139
if (!portableFolder .exists ())
140
140
portableFolder = null ;
141
141
142
+ File preferencesFile = null ;
143
+
144
+ // Do a first pass over the commandline arguments, the rest of them
145
+ // will be processed by the Base constructor. Note that this loop
146
+ // does not look at the last element of args, to prevent crashing
147
+ // when no parameter was specified to an option. Later, Base() will
148
+ // then show an error for these.
149
+ for (int i = 0 ; i < args .length - 1 ; i ++) {
150
+ if (args [i ].equals ("--preferences-file" ))
151
+ preferencesFile = new File (args [i + 1 ]);
152
+ }
153
+
142
154
// run static initialization that grabs all the prefs
143
- Preferences .init (args );
155
+ Preferences .init (preferencesFile );
144
156
145
157
try {
146
158
File versionFile = getContentFile ("lib/version.txt" );
@@ -402,7 +414,7 @@ public Base(String[] args) throws Exception {
402
414
i ++;
403
415
if (i >= args .length )
404
416
showError (null , _ ("Argument required for --preferences-file" ), 3 );
405
- // Argument should be already processed by Preferences.init (...)
417
+ // Argument should be already processed by Base.main (...)
406
418
continue ;
407
419
}
408
420
if (args [i ].startsWith ("--" ))
Original file line number Diff line number Diff line change @@ -223,7 +223,11 @@ public String toString() {
223
223
static boolean doSave = true ;
224
224
225
225
226
- static protected void init (String args []) {
226
+ static protected void init (File file ) {
227
+ if (file != null )
228
+ preferencesFile = file ;
229
+ else
230
+ preferencesFile = Base .getSettingsFile (Preferences .PREFS_FILE );
227
231
228
232
// start by loading the defaults, in case something
229
233
// important was deleted from the user prefs
@@ -255,17 +259,6 @@ static protected void init(String args[]) {
255
259
// clone the hash table
256
260
defaults = new Hashtable <String , String >(table );
257
261
258
- // next load user preferences file
259
- preferencesFile = Base .getSettingsFile (PREFS_FILE );
260
-
261
- // load a preferences file if specified on the command line
262
- if (args != null ) {
263
- for (int i = 0 ; i < args .length - 1 ; i ++) {
264
- if (args [i ].equals ("--preferences-file" ))
265
- preferencesFile = new File (args [i + 1 ]);
266
- }
267
- }
268
-
269
262
if (preferencesFile .exists ()) {
270
263
// load the previous preferences file
271
264
try {
You can’t perform that action at this time.
0 commit comments