Changeset 4667 in josm for trunk


Ignore:
Timestamp:
2011-12-19T00:02:30+01:00 (13 years ago)
Author:
Don-vip
Message:

fix #7162 - undoing multipolygon changes causes exception (NPE)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java

    r4649 r4667  
    280280        private void resetNodes() {
    281281            if (!nodes.isEmpty()) {
    282                 DataSet ds = nodes.get(0).getDataSet();
     282                DataSet ds = null;
     283                // Find DataSet (can be null for several nodes when undoing nodes creation, see #7162)
     284                for (Iterator<Node> it = nodes.iterator(); it.hasNext() && ds == null; ) {
     285                    ds = it.next().getDataSet();
     286                }
    283287                nodes.clear();
    284                 if (wayIds.size() == 1) {
     288                if (ds == null) {
     289                    // DataSet still not found. This should not happen, but a warning does no harm
     290                    System.err.println("Warning: DataSet not found while resetting nodes in Multipolygon. This should not happen, you may report it to JOSM developers.");
     291                } else if (wayIds.size() == 1) {
    285292                    Way w = (Way) ds.getPrimitiveById(wayIds.iterator().next(), OsmPrimitiveType.WAY);
    286293                    nodes.addAll(w.getNodes());
Note: See TracChangeset for help on using the changeset viewer.