Changeset 18399 in josm


Ignore:
Timestamp:
2022-03-13T13:40:25+01:00 (2 years ago)
Author:
stoecker
Message:

fix #21922 - patch by Bjoeni - GPX file marked as modified when saving session

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

Legend:

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

    r18287 r18399  
    10931093    }
    10941094
     1095    /**
     1096     * Put a key / value pair as a new attribute. Overrides key / value pair with the same key (if present).
     1097     *
     1098     * @param key the key
     1099     * @param value the value
     1100     */
    10951101    @Override
    10961102    public void put(String key, Object value) {
     1103        put(key, value, true);
     1104    }
     1105
     1106    /**
     1107     * Put a key / value pair as a new attribute. Overrides key / value pair with the same key (if present).
     1108     * Only sets the modified state when setModified is true.
     1109     *
     1110     * @param key the key
     1111     * @param value the value
     1112     * @param setModified whether to change the modified state
     1113     * @since 18399
     1114     */
     1115    public void put(String key, Object value, boolean setModified) {
    10971116        super.put(key, value);
    1098         invalidate();
     1117        fireInvalidate(setModified);
    10991118    }
    11001119
     
    11331152
    11341153    private void fireInvalidate(boolean setModified) {
     1154        if (setModified) {
     1155            setModified(true);
     1156        }
    11351157        if (updating || initializing) {
    11361158            suppressedInvalidate = true;
    11371159        } else {
    1138             if (setModified) {
    1139                 setModified(true);
    1140             }
    11411160            if (listeners.hasListeners()) {
    11421161                GpxDataChangeEvent e = new GpxDataChangeEvent(this);
     
    11591178     */
    11601179    public void endUpdate() {
    1161         boolean setModified = updating;
    11621180        updating = initializing = false;
    11631181        if (suppressedInvalidate) {
    1164             fireInvalidate(setModified);
     1182            fireInvalidate(false);
    11651183            suppressedInvalidate = false;
    11661184        }
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java

    r18211 r18399  
    8383    @Override
    8484    public void setColor(Color color) {
    85         setColorExtension(color);
     85        setColorExtensionGPXD(color, true);
    8686        colorCache = color;
    8787    }
    8888
    89     private void setColorExtension(Color color) {
     89    private void setColorExtensionGPXD(Color color, boolean invalidate) {
    9090        getExtensions().findAndRemove("gpxx", "DisplayColor");
    9191        if (color == null) {
     
    9494            getExtensions().addOrUpdate("gpxd", "color", String.format("#%02X%02X%02X", color.getRed(), color.getGreen(), color.getBlue()));
    9595        }
    96         fireInvalidate();
     96        colorFormat = ColorFormat.GPXD;
     97        if (invalidate) {
     98            fireInvalidate();
     99        }
    97100    }
    98101
     
    168171                getExtensions().addIfNotPresent("gpxx", "TrackExtension").getExtensions().addOrUpdate("gpxx", "DisplayColor", colorString);
    169172            } else if (cFormat == ColorFormat.GPXD) {
    170                 setColor(c);
     173                setColorExtensionGPXD(c, false);
    171174            }
    172175            colorFormat = cFormat;
  • trunk/src/org/openstreetmap/josm/io/GpxWriter.java

    r18287 r18399  
    124124            });
    125125        }
    126         data.put(META_TIME, (metaTime != null ? metaTime : Instant.now()).toString());
     126        data.put(META_TIME, (metaTime != null ? metaTime : Instant.now()).toString(), false);
    127127        data.endUpdate();
    128128
Note: See TracChangeset for help on using the changeset viewer.