Changeset 18908 in josm for trunk/src/org


Ignore:
Timestamp:
2023-12-13T16:54:29+01:00 (10 months ago)
Author:
taylor.smock
Message:

Fix #23341: Don't set paintstyles to nothing when paintstyles haven't been modified by the user

The original fix (r18907) was a short-term fix that reset paintstyles to the
default if the list was empty. This is not ideal, since people who have
deliberately made their paintstyle list empty now have to clear it every time
JOSM starts.

This patch fixes that by only attempting to remove potlatch2 if the user has
previously modified the painstyle list. The previous patch was necessary to get
most users back to a "known good" state, especially those that have never used
the style settings.

File:
1 edited

Legend:

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

    r18907 r18908  
    918918     */
    919919    private void updateMapPaintKnownDefaults() {
     920        final String mapPaintStyleEntriesPrefEntry = "mappaint.style.entries";
    920921        final String url = "url";
    921922        final String active = "active";
     
    933934        putList("mappaint.style.known-defaults", knownDefaults);
    934935
     936        // If the user hasn't set the entries, don't go through the removal process for potlatch 2. There is an issue
     937        // where it may clear all paintstyles (done when the user has never touched the style settings).
     938        if (!this.settingsMap.containsKey(mapPaintStyleEntriesPrefEntry)) {
     939            return;
     940        }
    935941        // Replace potlatch2 in the current style entries, but only if it is enabled. Otherwise, remove it.
    936         final List<Map<String, String>> styleEntries = new ArrayList<>(getListOfMaps("mappaint.style.entries"));
     942        final List<Map<String, String>> styleEntries = new ArrayList<>(getListOfMaps(mapPaintStyleEntriesPrefEntry));
    937943        final boolean potlatchEnabled = styleEntries.stream().filter(map -> potlatch2.equals(map.get(url)))
    938944                .anyMatch(map -> Boolean.parseBoolean(map.get(active)));
     
    946952            }
    947953        }
    948         putListOfMaps("mappaint.style.entries", styleEntries.isEmpty() ? null : styleEntries);
     954        putListOfMaps(mapPaintStyleEntriesPrefEntry, styleEntries);
    949955    }
    950956
Note: See TracChangeset for help on using the changeset viewer.