Changeset 17163 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2020-10-11T14:24:00+02:00 (4 years ago)
Author:
GerdP
Message:

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

  • use ChangeNodesCommand instead of ChangeCommand
  • use ChangePropertyCommand instead of ChangeCommand
  • remove unused parameter

Just a small step forward...

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r17141 r17163  
    2828import org.openstreetmap.josm.command.ChangeCommand;
    2929import org.openstreetmap.josm.command.ChangeNodesCommand;
     30import org.openstreetmap.josm.command.ChangePropertyCommand;
    3031import org.openstreetmap.josm.command.Command;
    3132import org.openstreetmap.josm.command.DeleteCommand;
     
    17191720    private void stripTags(Collection<Way> ways) {
    17201721        for (Way w : ways) {
    1721             final Way wayWithoutTags = new Way(w);
    1722             wayWithoutTags.removeAll();
    1723             cmds.add(new ChangeCommand(w, wayWithoutTags));
     1722            cmds.add(new ChangePropertyCommand(Collections.singleton(w), Collections.emptyMap()));
    17241723        }
    17251724        /* I18N: current action printed in status display */
  • trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java

    r16781 r17163  
    351351
    352352        // Figure out the order of relation members (if any).
    353         Analysis analysis = analyseSplit(way, wayToKeep, newWays, indexOfWayToKeep);
     353        Analysis analysis = analyseSplit(way, wayToKeep, newWays);
    354354
    355355        // If there are relations that cannot be split properly without downloading more members,
     
    406406                // If missing relation members were downloaded, perform the analysis again to find the relation
    407407                // member order for all relations.
    408                 analysis = analyseSplit(way, wayToKeep, newWays, indexOfWayToKeep);
     408                analysis = analyseSplit(way, wayToKeep, newWays);
    409409                return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep));
    410410            case GO_AHEAD_WITHOUT_DOWNLOADS:
     
    421421    static Analysis analyseSplit(Way way,
    422422                                 Way wayToKeep,
    423                                  List<Way> newWays,
    424                                  int indexOfWayToKeep) {
     423                                 List<Way> newWays) {
    425424        Collection<Command> commandList = new ArrayList<>();
    426425        Collection<String> nowarnroles = Config.getPref().getList("way.split.roles.nowarn",
     
    430429        final Way changedWay = new Way(way);
    431430        changedWay.setNodes(wayToKeep.getNodes());
    432         commandList.add(new ChangeCommand(way, changedWay));
    433 
     431        commandList.add(new ChangeNodesCommand(way, changedWay.getNodes()));
    434432        for (Way wayToAdd : newWays) {
    435433            commandList.add(new AddCommand(way.getDataSet(), wayToAdd));
     
    559557            }
    560558        }
    561 
     559        changedWay.setNodes(null); // see #19885
    562560        return new Analysis(relationAnalyses, commandList, warnings, numberOfRelations);
    563561    }
Note: See TracChangeset for help on using the changeset viewer.