Changeset 17113 in josm


Ignore:
Timestamp:
2020-10-08T16:18:33+02:00 (4 years ago)
Author:
GerdP
Message:

fix #19895: TagChecker cannot cope with read-only datasets.
Use different method to create clones for special case where we test agains deprecated.mapcss rules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r17010 r17113  
    3939import org.openstreetmap.josm.command.SequenceCommand;
    4040import org.openstreetmap.josm.data.osm.AbstractPrimitive;
    41 import org.openstreetmap.josm.data.osm.Node;
     41import org.openstreetmap.josm.data.osm.DataSet;
    4242import org.openstreetmap.josm.data.osm.OsmPrimitive;
    4343import org.openstreetmap.josm.data.osm.OsmUtils;
     
    4646import org.openstreetmap.josm.data.osm.TagMap;
    4747import org.openstreetmap.josm.data.osm.Tagged;
    48 import org.openstreetmap.josm.data.osm.Way;
     48import org.openstreetmap.josm.data.osm.visitor.MergeSourceBuildingVisitor;
    4949import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper;
    5050import org.openstreetmap.josm.data.validation.OsmValidator;
     
    972972
    973973        int unchangedDeprecated = countDeprecated(p);
     974
     975        // see #19895: create deep clone. This complex method works even with locked files
     976        MergeSourceBuildingVisitor builder = new MergeSourceBuildingVisitor(p.getDataSet());
     977        p.accept(builder);
     978        DataSet clonedDs = builder.build();
     979        OsmPrimitive clone = clonedDs.getPrimitiveById(p.getPrimitiveId());
     980
    974981        Iterator<String> iter = fixVals.iterator();
    975         OsmPrimitive clone;
    976         if (p instanceof Node) {
    977             clone = new Node((Node) p);
    978         } else if (p instanceof Way) {
    979             clone = new Way((Way) p);
    980         } else if (p instanceof Relation) {
    981             clone = new Relation((Relation) p);
    982         } else {
    983             return; // should not happen
    984         }
    985982        while (iter.hasNext()) {
    986983            clone.put(key, iter.next());
     
    989986        }
    990987    }
     988
    991989
    992990    private int countDeprecated(OsmPrimitive p) {
Note: See TracChangeset for help on using the changeset viewer.