Changeset 9311 in josm


Ignore:
Timestamp:
2016-01-04T22:43:13+01:00 (8 years ago)
Author:
simon04
Message:

fix #6044 - Do not overwrite preferences_backup when loading preferences fails

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r9296 r9311  
    151151
    152152    /**
     153     * Indicates whether {@link #init(boolean)} completed successfully.
     154     * Used to decide whether to write backup preference file in {@link #save()}
     155     */
     156    protected boolean initSuccessful = false;
     157
     158    /**
    153159     * Interface for a preference value.
    154160     *
     
    862868
    863869        // Backup old preferences if there are old preferences
    864         if (prefFile.exists()) {
     870        if (prefFile.exists() && prefFile.length() > 0 && initSuccessful) {
    865871            Utils.copyFile(prefFile, backupFile);
    866872        }
     
    921927     */
    922928    public void init(boolean reset) {
     929        initSuccessful = false;
    923930        // get the preferences.
    924931        File prefDir = getPreferencesDirectory();
     
    975982        try {
    976983            load();
     984            initSuccessful = true;
    977985        } catch (Exception e) {
    978986            Main.error(e);
Note: See TracChangeset for help on using the changeset viewer.