Changeset 18403 in josm for trunk/src


Ignore:
Timestamp:
2022-03-21T22:01:04+01:00 (3 years ago)
Author:
taylor.smock
Message:

fix #21953: Remember custom overpass servers

This was caused by not adding the new server to the HistoryComboBox list
prior to saving the list.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OverpassServerPanel.java

    r18173 r18403  
    1616import org.openstreetmap.josm.io.OverpassDownloadReader;
    1717import org.openstreetmap.josm.tools.GBC;
     18import org.openstreetmap.josm.tools.Utils;
    1819
    1920/**
     
    5152     */
    5253    public final void saveToPreferences() {
    53         OverpassDownloadReader.OVERPASS_SERVER.put(overpassServer.getText());
     54        // Get the new server -- add the trailing `/` if it does not exist to avoid duplicate entries.
     55        // Other code locations assume that the URL has a trailing `/` as well.
     56        String newServer = Utils.strip(overpassServer.getText());
     57        if (!newServer.endsWith("/")) {
     58            newServer += "/";
     59        }
     60        OverpassDownloadReader.OVERPASS_SERVER.put(newServer);
     61        // Ensure that the new overpass server is added to history
     62        overpassServer.setText(newServer);
     63        overpassServer.addCurrentItemToHistory();
    5464        overpassServer.getModel().prefs().save(OverpassDownloadReader.OVERPASS_SERVER_HISTORY);
    5565        OverpassDownloadReader.FOR_MULTI_FETCH.put(forMultiFetch.isSelected());
Note: See TracChangeset for help on using the changeset viewer.