Changeset 17359 in josm


Ignore:
Timestamp:
2020-11-25T13:23:30+01:00 (3 years ago)
Author:
GerdP
Message:

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

  • revert changes made in r17358 in SplitWayCommand , they break a unit test and I do not yet see why
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java

    r17358 r17359  
    1717import java.util.HashSet;
    1818import java.util.Iterator;
    19 import java.util.LinkedHashSet;
    2019import java.util.LinkedList;
    2120import java.util.List;
     
    9190     * @param newSelection The new list of selected primitives ids (which is saved for later retrieval with {@link #getNewSelection})
    9291     * @param originalWay The original way being split (which is saved for later retrieval with {@link #getOriginalWay})
    93      * @param newWays The resulting new ways (which is saved for later retrieval with {@link #getNewWays})
     92     * @param newWays The resulting new ways (which is saved for later retrieval with {@link #getOriginalWay})
    9493     */
    9594    public SplitWayCommand(String name, Collection<Command> commandList,
     
    403402                } catch (OsmTransferException e) {
    404403                    ExceptionDialogUtil.explainException(e);
    405                     analysis.cleanup();
    406404                    return Optional.empty();
    407405                }
    408406                // If missing relation members were downloaded, perform the analysis again to find the relation
    409407                // member order for all relations.
    410                 analysis.cleanup();
    411408                analysis = analyseSplit(way, wayToKeep, newWays);
    412                 break;
     409                return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep));
    413410            case GO_AHEAD_WITHOUT_DOWNLOADS:
    414411                // Proceed with the split with the information we have.
    415412                // This can mean that there are no missing members we want, or that the user chooses to continue
    416413                // the split without downloading them.
    417                 break;
     414                return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep));
    418415            case USER_ABORTED:
    419416            default:
    420417                return Optional.empty();
    421         }
    422         try {
    423             return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep));
    424         } finally {
    425             // see #19885
    426             wayToKeep.setNodes(null);
    427             analysis.cleanup();
    428418        }
    429419    }
     
    475465                    }
    476466                    if (c == null) {
    477                         c = new Relation(r); // #19885: will be removed later
     467                        c = new Relation(r);
    478468                    }
    479469
     
    562552                }
    563553            }
     554
     555            if (c != null) {
     556                commandList.add(new ChangeCommand(r.getDataSet(), r, c));
     557            }
    564558        }
    565559        changedWay.setNodes(null); // see #19885
     
    581575            warningTypes = warnings;
    582576            this.numberOfRelations = numberOfRelations;
    583         }
    584 
    585         /**
    586          * Unlink temporary copies of relations. See #19885
    587          */
    588         void cleanup() {
    589             for (RelationAnalysis ra : relationAnalyses) {
    590                 if (ra.relation.getDataSet() == null)
    591                     ra.relation.setMembers(null);
    592             }
    593577        }
    594578
     
    704688        }
    705689
    706         Set<Relation> modifiedRelations = new LinkedHashSet<>();
    707690        // Perform the split.
    708691        for (RelationAnalysis relationAnalysis : analysis.getRelationAnalyses()) {
     
    746729                }
    747730            }
    748             modifiedRelations.add(relation);
    749         }
    750         for (Relation r : modifiedRelations) {
    751             DataSet ds = way.getDataSet();
    752             Relation orig = (Relation) ds.getPrimitiveById(r);
    753             analysis.getCommands().add(new ChangeMembersCommand(orig, new ArrayList<>(r.getMembers())));
    754             r.setMembers(null); // see #19885
    755731        }
    756732
Note: See TracChangeset for help on using the changeset viewer.