Changeset 18001 in josm for trunk/src


Ignore:
Timestamp:
2021-07-11T14:39:42+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #21095 - see #21041 - fix NPE when opening the preset editor with new objects

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r17981 r18001  
    238238     * @param ways ways to clone
    239239     * @param relations relations to clone
    240      * @since 17981
    241      */
    242     public void clonePrimitives(Iterable<Node> nodes, Iterable<Way> ways, Iterable<Relation> relations) {
     240     * @return the map of cloned primitives indexed by their original version
     241     * @since 18001
     242     */
     243    public Map<OsmPrimitive, OsmPrimitive> clonePrimitives(Iterable<Node> nodes, Iterable<Way> ways, Iterable<Relation> relations) {
    243244        Map<OsmPrimitive, OsmPrimitive> primMap = new HashMap<>();
    244245        for (Node n : nodes) {
     
    268269                    .collect(Collectors.toList()));
    269270        }
     271        return primMap;
    270272    }
    271273
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetValidation.java

    r17981 r18001  
    8080        DataSet ds = new DataSet();
    8181        Collection<OsmPrimitive> primitives = FilterModel.getAffectedPrimitives(singleton(original));
    82         ds.clonePrimitives(
     82        OsmPrimitive primitive = ds.clonePrimitives(
    8383                new SubclassFilteredCollection<>(primitives, INode.class::isInstance),
    8484                new SubclassFilteredCollection<>(primitives, IWay.class::isInstance),
    85                 new SubclassFilteredCollection<>(primitives, IRelation.class::isInstance));
    86         OsmPrimitive primitive = ds.getPrimitiveById(original.getOsmPrimitiveId());
     85                new SubclassFilteredCollection<>(primitives, IRelation.class::isInstance))
     86                .get(original);
    8787        Command command = TaggingPreset.createCommand(singleton(primitive), changedTags);
    8888        if (command != null) {
Note: See TracChangeset for help on using the changeset viewer.