Changeset 17221 in josm


Ignore:
Timestamp:
2020-10-17T10:23:03+02:00 (4 years ago)
Author:
GerdP
Message:

see #19885: memory leak with "temporary" objects in validator and actions

  • no need to clone relation, replace ChangeCommand by ChangeMembersCommand

Simplifies code and fixes memory leak

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

    r16761 r17221  
    1919import java.util.stream.IntStream;
    2020
    21 import org.openstreetmap.josm.command.ChangeCommand;
     21import org.openstreetmap.josm.command.ChangeMembersCommand;
    2222import org.openstreetmap.josm.command.Command;
    2323import org.openstreetmap.josm.data.coor.EastNorth;
     
    743743            if (primitives.size() >= 2 && primitives.get(0) instanceof Relation) {
    744744                Relation oldRel = (Relation) primitives.get(0);
    745                 Relation newRel = new Relation(oldRel);
    746745                List<OsmPrimitive> repeatedPrims = primitives.subList(1, primitives.size());
    747746                List<RelationMember> oldMembers = oldRel.getMembers();
     
    752751                for (RelationMember rm : oldMembers) {
    753752                    if (toRemove.contains(rm.getMember())) {
    754                         if (!found.contains(rm.getMember())) {
    755                             found.add(rm.getMember());
     753                        if (found.add(rm.getMember())) {
    756754                            newMembers.add(rm);
    757755                        }
     
    760758                    }
    761759                }
    762                 newRel.setMembers(newMembers);
    763                 return new ChangeCommand(oldRel, newRel);
     760                return new ChangeMembersCommand(oldRel, newMembers);
    764761            }
    765762        }
Note: See TracChangeset for help on using the changeset viewer.