Changeset 13513 in josm for trunk/src/org


Ignore:
Timestamp:
2018-03-11T14:21:34+01:00 (21 months ago)
Author:
Don-vip
Message:

fix #16078 - avoid NPE in PurgeCommand with null relations

File:
1 edited

Legend:

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

    r13420 r13513  
    160160    public static List<OsmPrimitive> topoSort(Collection<OsmPrimitive> sel) {
    161161        Set<OsmPrimitive> in = new HashSet<>(sel);
    162 
    163162        List<OsmPrimitive> out = new ArrayList<>(in.size());
     163        Set<Relation> inR = new HashSet<>();
    164164
    165165        // Nodes not deleted in the first pass
     
    201201                }
    202202                out.add(w);
     203            } else if (u instanceof Relation) {
     204                inR.add((Relation) u);
    203205            }
    204206        }
     
    207209            throw new AssertionError("topo sort algorithm failed (nodes remaining)");
    208210
    209         /**
    210           * Rest are relations. Do topological sorting on a DAG where each
    211           * arrow points from child to parent. (Because it is faster to
    212           * loop over getReferrers() than getMembers().)
    213           */
    214         @SuppressWarnings({ "unchecked", "rawtypes" })
    215         Set<Relation> inR = (Set) in;
     211        // Do topological sorting on a DAG where each arrow points from child to parent.
     212        //  (Because it is faster to loop over getReferrers() than getMembers().)
    216213
    217214        Map<Relation, Integer> numChilds = new HashMap<>();
Note: See TracChangeset for help on using the changeset viewer.