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 {
139139 if (!portableFolder .exists ())
140140 portableFolder = null ;
141141
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+
142154 // run static initialization that grabs all the prefs
143- Preferences .init (args );
155+ Preferences .init (preferencesFile );
144156
145157 try {
146158 File versionFile = getContentFile ("lib/version.txt" );
@@ -402,7 +414,7 @@ public Base(String[] args) throws Exception {
402414 i ++;
403415 if (i >= args .length )
404416 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 (...)
406418 continue ;
407419 }
408420 if (args [i ].startsWith ("--" ))
Original file line number Diff line number Diff line change @@ -223,7 +223,11 @@ public String toString() {
223223 static boolean doSave = true ;
224224
225225
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 );
227231
228232 // start by loading the defaults, in case something
229233 // important was deleted from the user prefs
@@ -255,17 +259,6 @@ static protected void init(String args[]) {
255259 // clone the hash table
256260 defaults = new Hashtable <String , String >(table );
257261
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-
269262 if (preferencesFile .exists ()) {
270263 // load the previous preferences file
271264 try {
You can’t perform that action at this time.
0 commit comments