Changeset 12969 in josm


Ignore:
Timestamp:
2017-10-09T21:26:26+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15420 - should fix NPE in ParallelWays.copyNode (probably caused by an incomplete or empty way)

Location:
trunk/src/org/openstreetmap/josm/actions/mapmode
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java

    r12630 r12969  
    505505            return false;
    506506
     507        sourceWays.removeIf(w -> w.isIncomplete() || w.getNodesCount() == 0);
     508
    507509        if (!sourceWays.contains(referenceSegment.way)) {
    508510            clearSourceWays();
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWays.java

    r12726 r12969  
    4444     */
    4545    public ParallelWays(Collection<Way> sourceWays, boolean copyTags, int refWayIndex) {
    46         // Possible/sensible to use PrimetiveDeepCopy here?
     46        // Possible/sensible to use PrimitiveDeepCopy here?
    4747
    4848        // Make a deep copy of the ways, keeping the copied ways connected
     
    5050        Map<Node, Node> splitNodeMap = new HashMap<>(sourceWays.size());
    5151        for (Way w : sourceWays) {
    52             if (!splitNodeMap.containsKey(w.firstNode())) {
    53                 splitNodeMap.put(w.firstNode(), copyNode(w.firstNode(), copyTags));
    54             }
    55             if (!splitNodeMap.containsKey(w.lastNode())) {
    56                 splitNodeMap.put(w.lastNode(), copyNode(w.lastNode(), copyTags));
    57             }
     52            copyNodeInMap(splitNodeMap, w.firstNode(), copyTags);
     53            copyNodeInMap(splitNodeMap, w.lastNode(), copyTags);
    5854        }
    5955        ways = new ArrayList<>(sourceWays.size());
     
    125121    }
    126122
     123    private static void copyNodeInMap(Map<Node, Node> splitNodeMap, Node node, boolean copyTags) {
     124        if (!splitNodeMap.containsKey(node)) {
     125            splitNodeMap.put(node, copyNode(node, copyTags));
     126        }
     127    }
     128
    127129    /**
    128130     * Determines if the nodes graph form a closed path
Note: See TracChangeset for help on using the changeset viewer.