Changeset 17138 in josm


Ignore:
Timestamp:
2020-10-10T07:32:49+02:00 (3 weeks ago)
Author:
GerdP
Message:

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

  • use ChangeNodesCommand instead of ChangeCommand
  • remove fake parent way in AlignInCircleAction
Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r16442 r17138  
    120120            Way closedWay = new Way(w);
    121121            closedWay.addNode(w.firstNode());
    122             List<Way> usedWays = new ArrayList<>(1);
    123             usedWays.add(closedWay);
    124             nodes = collectNodesAnticlockwise(usedWays);
     122            nodes = collectNodesAnticlockwise(Collections.singletonList(closedWay));
     123            closedWay.setNodes(null);
    125124        } else if (!ways.isEmpty() && checkWaysArePolygon(ways)) {
    126125            // Case 2
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r17102 r17138  
    489489            n.addAll(ws.way.getNodes().subList(0, ws.lowerIndex + 1));
    490490
    491             Way wnew = new Way(ws.way);
    492             wnew.setNodes(n);
    493 
    494             return new ChangeCommand(ws.way, wnew);
     491            return new ChangeNodesCommand(ws.way, n);
    495492        }
    496493
     
    501498        n2.addAll(ws.way.getNodes().subList(ws.lowerIndex + 1, ws.way.getNodesCount()));
    502499
    503         Way wnew = new Way(ws.way);
    504 
    505500        if (n1.size() < 2) {
    506             wnew.setNodes(n2);
    507             return new ChangeCommand(ws.way, wnew);
     501            return new ChangeNodesCommand(ws.way, n2);
    508502        } else if (n2.size() < 2) {
    509             wnew.setNodes(n1);
    510             return new ChangeCommand(ws.way, wnew);
     503            return new ChangeNodesCommand(ws.way, n1);
    511504        } else {
    512505            return SplitWayCommand.splitWay(ws.way, Arrays.asList(n1, n2), Collections.<OsmPrimitive>emptyList());
Note: See TracChangeset for help on using the changeset viewer.