Changeset 17215 in josm


Ignore:
Timestamp:
2020-10-16T15:22:57+02:00 (12 days ago)
Author:
GerdP
Message:

see #19885: memory leak with "temporary" objects in validator and actions
use new ChangeMembersCommand in PropertiesDialog

Location:
trunk/src/org/openstreetmap/josm/gui/dialogs/properties
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r17188 r17215  
    5656import org.openstreetmap.josm.actions.relation.DuplicateRelationAction;
    5757import org.openstreetmap.josm.actions.relation.EditRelationAction;
    58 import org.openstreetmap.josm.command.ChangeCommand;
     58import org.openstreetmap.josm.command.ChangeMembersCommand;
    5959import org.openstreetmap.josm.command.ChangePropertyCommand;
    6060import org.openstreetmap.josm.command.Command;
     
    11541154                return;
    11551155
    1156             Relation rel = new Relation(cur);
     1156            Relation copy = new Relation(cur);
    11571157            for (OsmPrimitive primitive: OsmDataManager.getInstance().getInProgressSelection()) {
    1158                 rel.removeMembersFor(primitive);
    1159             }
    1160             UndoRedoHandler.getInstance().add(new ChangeCommand(cur, rel));
     1158                copy.removeMembersFor(primitive);
     1159            }
     1160            UndoRedoHandler.getInstance().add(new ChangeMembersCommand(cur, copy.getMembers()));
     1161            copy.setMembers(null); // see #19885
    11611162
    11621163            tagTable.clearSelection();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/RelationRoleEditor.java

    r16549 r17215  
    99import javax.swing.JOptionPane;
    1010
    11 import org.openstreetmap.josm.command.ChangeCommand;
     11import org.openstreetmap.josm.command.ChangeMembersCommand;
    1212import org.openstreetmap.josm.data.UndoRedoHandler;
    1313import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
     
    4545            return;
    4646        }
    47         final Relation newRelation = new Relation(relation);
    48         final List<RelationMember> newMembers = newRelation.getMembers();
     47        final List<RelationMember> newMembers = relation.getMembers();
    4948        newMembers.replaceAll(m -> members.contains(m) ? new RelationMember(newRole, m.getMember()) : m);
    50         newRelation.setMembers(newMembers);
    51         UndoRedoHandler.getInstance().add(new ChangeCommand(relation, newRelation));
     49        UndoRedoHandler.getInstance().add(new ChangeMembersCommand(relation, newMembers));
    5250    }
    5351}
Note: See TracChangeset for help on using the changeset viewer.