Changeset 6302 in josm


Ignore:
Timestamp:
2013-10-06T19:14:04+02:00 (6 years ago)
Author:
Don-vip
Message:

see #7465 - Raise an error when a plugin replaces a way with a zero-node way (such as reverter before v30000)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/ChangeCommand.java

    r5077 r6302  
    1111import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1212import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     13import org.openstreetmap.josm.data.osm.Way;
    1314import org.openstreetmap.josm.gui.DefaultNameFormatter;
    1415import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     16import org.openstreetmap.josm.tools.CheckParameterUtil;
    1517import org.openstreetmap.josm.tools.ImageProvider;
    1618
     
    2628    private final OsmPrimitive newOsm;
    2729
    28 
    2930    public ChangeCommand(OsmPrimitive osm, OsmPrimitive newOsm) {
    3031        super();
    3132        this.osm = osm;
    3233        this.newOsm = newOsm;
     34        sanityChecks();
    3335    }
    3436
     
    3739        this.osm = osm;
    3840        this.newOsm = newOsm;
     41        sanityChecks();
     42    }
     43   
     44    private void sanityChecks() {
     45        CheckParameterUtil.ensureParameterNotNull(osm, "osm");
     46        CheckParameterUtil.ensureParameterNotNull(newOsm, "newOsm");
     47        if (newOsm instanceof Way) {
     48            // Do not allow to create empty ways (see #7465)
     49            if (((Way)newOsm).getNodesCount() == 0) {
     50                throw new IllegalArgumentException(tr("New way {0} has 0 nodes", newOsm));
     51            }
     52        }
    3953    }
    4054
Note: See TracChangeset for help on using the changeset viewer.