Changeset 19012 in josm


Ignore:
Timestamp:
2024-03-07T20:05:10+01:00 (2 months ago)
Author:
taylor.smock
Message:

Fix #23437: Offer to reset JOSM if JOSM fails to finish startup multiple times

File:
1 edited

Legend:

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

    r18999 r19012  
    5555import javax.swing.InputMap;
    5656import javax.swing.JComponent;
     57import javax.swing.JDialog;
    5758import javax.swing.JLabel;
    5859import javax.swing.JOptionPane;
     
    184185     */
    185186    private static volatile List<String> commandLineArgs;
     187    /**
     188     * The preference key for the startup failure counter
     189     */
     190    private static final String PREF_STARTUP_FAILURE_COUNTER = "josm.startup.failure.count";
    186191
    187192    /**
     
    878883        checkIPv6();
    879884
     885        // After IPv6 check since that may restart JOSM, must be after Preferences.main().init()
     886        final int failures = prefs.getInt(PREF_STARTUP_FAILURE_COUNTER, 0);
     887        // Always increment failures
     888        prefs.putInt(PREF_STARTUP_FAILURE_COUNTER, failures + 1);
     889        if (failures > 3) {
     890            final int selection = JOptionPane.showOptionDialog(new JDialog(),
     891                    tr("JOSM has failed to start up {0} times. Reset JOSM?", failures),
     892                    tr("Reset JOSM?"),
     893                    JOptionPane.YES_NO_OPTION,
     894                    JOptionPane.ERROR_MESSAGE,
     895                    null,
     896                    null,
     897                    null);
     898            if (selection == JOptionPane.YES_OPTION) {
     899                Preferences.main().init(true);
     900            }
     901        }
     902
    880903        processOffline(args);
    881904
     
    10101033            }
    10111034            mainFrame.setVisible(true);
     1035            Config.getPref().put(PREF_STARTUP_FAILURE_COUNTER, null);
    10121036        });
    10131037
Note: See TracChangeset for help on using the changeset viewer.