Changeset 12273 in josm for trunk


Ignore:
Timestamp:
2017-05-29T15:43:26+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #14850 - NPE on launch: make sure RestartAction (and all the GUI stuff behind) is not constructed before GUI is fully initialized

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/RestartAction.java

    r11650 r12273  
    5656    @Override
    5757    public void actionPerformed(ActionEvent e) {
     58        try {
     59            restartJOSM();
     60        } catch (IOException ex) {
     61            Main.error(ex);
     62        }
     63    }
     64
     65    /**
     66     * Determines if restarting the application should be possible on this platform.
     67     * @return {@code true} if the mandatory system property {@code sun.java.command} is defined, {@code false} otherwise.
     68     * @since 5951
     69     */
     70    public static boolean isRestartSupported() {
     71        return System.getProperty("sun.java.command") != null;
     72    }
     73
     74    /**
     75     * Restarts the current Java application.
     76     * @throws IOException in case of any I/O error
     77     */
     78    public static void restartJOSM() throws IOException {
    5879        // If JOSM has been started with property 'josm.restart=true' this means
    5980        // it is executed by a start script that can handle restart.
     
    6485        }
    6586
    66         try {
    67             restartJOSM();
    68         } catch (IOException ex) {
    69             Main.error(ex);
    70         }
    71     }
    72 
    73     /**
    74      * Determines if restarting the application should be possible on this platform.
    75      * @return {@code true} if the mandatory system property {@code sun.java.command} is defined, {@code false} otherwise.
    76      * @since 5951
    77      */
    78     public static boolean isRestartSupported() {
    79         return System.getProperty("sun.java.command") != null;
    80     }
    81 
    82     /**
    83      * Restarts the current Java application.
    84      * @throws IOException in case of any I/O error
    85      */
    86     public static void restartJOSM() throws IOException {
    8787        if (isRestartSupported() && !Main.exitJosm(false, 0, SaveLayersDialog.Reason.RESTART)) return;
    8888        final List<String> cmd;
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r12150 r12273  
    498498                    Main.info(tr("Detected no useable IPv6 network, prefering IPv4 over IPv6 after next restart."));
    499499                    Main.pref.put("validated.ipv6", hasv6); // be sure it is stored before the restart!
    500                     new RestartAction().actionPerformed(null);
     500                    try {
     501                        RestartAction.restartJOSM();
     502                    } catch (IOException e) {
     503                        Main.error(e);
     504                    }
    501505                }
    502506                Main.pref.put("validated.ipv6", hasv6);
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r11974 r12273  
    610610                        Main.pref.putCollection("plugins", plugins);
    611611                        // restart
    612                         new RestartAction().actionPerformed(null);
     612                        try {
     613                            RestartAction.restartJOSM();
     614                        } catch (IOException e) {
     615                            Main.error(e);
     616                        }
    613617                    } else {
    614618                        Main.warn("No plugin downloaded, restart canceled");
Note: See TracChangeset for help on using the changeset viewer.