Changeset 17220 in josm for trunk


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

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

  • replace ChangeCommand by ChangeMembersCommand
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModel.java

    r17140 r17220  
    2020import javax.swing.table.DefaultTableModel;
    2121
    22 import org.openstreetmap.josm.command.ChangeCommand;
     22import org.openstreetmap.josm.command.ChangeMembersCommand;
    2323import org.openstreetmap.josm.command.Command;
    2424import org.openstreetmap.josm.data.osm.Node;
     
    364364
    365365    protected Command buildResolveCommand(Relation relation, OsmPrimitive newPrimitive) {
    366         final Relation modifiedRelation = new Relation(relation);
    367         modifiedRelation.setMembers(null);
     366        List<RelationMember> modifiedMemberList = new ArrayList<>();
    368367        boolean isChanged = false;
    369368        for (int i = 0; i < relation.getMembersCount(); i++) {
     
    371370            RelationMemberConflictDecision decision = getDecision(relation, i);
    372371            if (decision == null) {
    373                 modifiedRelation.addMember(member);
     372                modifiedMemberList.add(member);
    374373            } else {
    375374                switch(decision.getDecision()) {
    376375                case KEEP:
    377376                    final RelationMember newMember = new RelationMember(decision.getRole(), newPrimitive);
    378                     modifiedRelation.addMember(newMember);
     377                    modifiedMemberList.add(newMember);
    379378                    isChanged |= !member.equals(newMember);
    380379                    break;
     
    389388            }
    390389        }
    391         if (isChanged)
    392             return new ChangeCommand(relation, modifiedRelation);
    393         modifiedRelation.setMembers(null); // see #19885
    394         return null;
     390        return isChanged ? new ChangeMembersCommand(relation, modifiedMemberList) : null;
    395391    }
    396392
Note: See TracChangeset for help on using the changeset viewer.