Ignore:
Timestamp:
2016-06-20T23:54:39+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #13009 - NPE on startup of JOSM (patch by michael2402) - gsoc-core

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r10432 r10442  
    317317        initApplicationPreferences();
    318318
     319        Policy.setPolicy(new Policy() {
     320            // Permissions for plug-ins loaded when josm is started via webstart
     321            private PermissionCollection pc;
     322
     323            {
     324                pc = new Permissions();
     325                pc.add(new AllPermission());
     326            }
     327
     328            @Override
     329            public PermissionCollection getPermissions(CodeSource codesource) {
     330                return pc;
     331            }
     332        });
     333
     334        Thread.setDefaultUncaughtExceptionHandler(new BugReportExceptionHandler());
     335
     336        // initialize the platform hook, and
     337        Main.determinePlatformHook();
     338        // call the really early hook before we do anything else
     339        Main.platform.preStartupHook();
     340
     341        Main.COMMAND_LINE_ARGS.addAll(Arrays.asList(argArray));
     342
     343        if (args.containsKey(Option.VERSION)) {
     344            System.out.println(Version.getInstance().getAgentString());
     345            System.exit(0);
     346        }
     347
     348        if (args.containsKey(Option.DEBUG) || args.containsKey(Option.TRACE)) {
     349            // Enable JOSM debug level
     350            logLevel = 4;
     351            Main.info(tr("Printing debugging messages to console"));
     352        }
     353
     354        boolean skipLoadingPlugins = false;
     355        if (args.containsKey(Option.SKIP_PLUGINS)) {
     356            skipLoadingPlugins = true;
     357            Main.info(tr("Plugin loading skipped"));
     358        }
     359
     360        if (args.containsKey(Option.TRACE)) {
     361            // Enable JOSM debug level
     362            logLevel = 5;
     363            // Enable debug in OAuth signpost via system preference, but only at trace level
     364            Utils.updateSystemProperty("debug", "true");
     365            Main.info(tr("Enabled detailed debug level (trace)"));
     366        }
     367
     368        Main.pref.init(args.containsKey(Option.RESET_PREFERENCES));
     369
     370        if (args.containsKey(Option.SET)) {
     371            for (String i : args.get(Option.SET)) {
     372                String[] kv = i.split("=", 2);
     373                Main.pref.put(kv[0], "null".equals(kv[1]) ? null : kv[1]);
     374            }
     375        }
     376
     377        if (!languageGiven) {
     378            I18n.set(Main.pref.get("language", null));
     379        }
     380        Main.pref.updateSystemProperties();
     381
     382        checkIPv6();
     383
     384        // asking for help? show help and exit
     385        if (args.containsKey(Option.HELP)) {
     386            showHelp();
     387            System.exit(0);
     388        }
     389
     390        processOffline(args);
     391
     392        Main.platform.afterPrefStartupHook();
     393
     394        FontsManager.initialize();
     395
     396        I18n.setupLanguageFonts();
     397
    319398        // Can only be called after preferences are initialized.
    320399        // We can move this to MainPanel constructor as soon as noone depends on Main#panel any more.
     
    325404            }
    326405        });
    327 
    328         Policy.setPolicy(new Policy() {
    329             // Permissions for plug-ins loaded when josm is started via webstart
    330             private PermissionCollection pc;
    331 
    332             {
    333                 pc = new Permissions();
    334                 pc.add(new AllPermission());
    335             }
    336 
    337             @Override
    338             public PermissionCollection getPermissions(CodeSource codesource) {
    339                 return pc;
    340             }
    341         });
    342 
    343         Thread.setDefaultUncaughtExceptionHandler(new BugReportExceptionHandler());
    344 
    345         // initialize the platform hook, and
    346         Main.determinePlatformHook();
    347         // call the really early hook before we do anything else
    348         Main.platform.preStartupHook();
    349 
    350         Main.COMMAND_LINE_ARGS.addAll(Arrays.asList(argArray));
    351 
    352         if (args.containsKey(Option.VERSION)) {
    353             System.out.println(Version.getInstance().getAgentString());
    354             System.exit(0);
    355         }
    356 
    357         if (args.containsKey(Option.DEBUG) || args.containsKey(Option.TRACE)) {
    358             // Enable JOSM debug level
    359             logLevel = 4;
    360             Main.info(tr("Printing debugging messages to console"));
    361         }
    362 
    363         boolean skipLoadingPlugins = false;
    364         if (args.containsKey(Option.SKIP_PLUGINS)) {
    365             skipLoadingPlugins = true;
    366             Main.info(tr("Plugin loading skipped"));
    367         }
    368 
    369         if (args.containsKey(Option.TRACE)) {
    370             // Enable JOSM debug level
    371             logLevel = 5;
    372             // Enable debug in OAuth signpost via system preference, but only at trace level
    373             Utils.updateSystemProperty("debug", "true");
    374             Main.info(tr("Enabled detailed debug level (trace)"));
    375         }
    376 
    377         Main.pref.init(args.containsKey(Option.RESET_PREFERENCES));
    378 
    379         if (args.containsKey(Option.SET)) {
    380             for (String i : args.get(Option.SET)) {
    381                 String[] kv = i.split("=", 2);
    382                 Main.pref.put(kv[0], "null".equals(kv[1]) ? null : kv[1]);
    383             }
    384         }
    385 
    386         if (!languageGiven) {
    387             I18n.set(Main.pref.get("language", null));
    388         }
    389         Main.pref.updateSystemProperties();
    390 
    391         checkIPv6();
    392 
    393         // asking for help? show help and exit
    394         if (args.containsKey(Option.HELP)) {
    395             showHelp();
    396             System.exit(0);
    397         }
    398 
    399         processOffline(args);
    400 
    401         Main.platform.afterPrefStartupHook();
    402 
    403         FontsManager.initialize();
    404 
    405         I18n.setupLanguageFonts();
    406406
    407407        WindowGeometry geometry = WindowGeometry.mainWindow("gui.geometry",
Note: See TracChangeset for help on using the changeset viewer.