Ignore:
Timestamp:
2020-11-25T11:50:22+01:00 (3 years ago)
Author:
GerdP
Message:

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

  • (hopefully) fix memory leaks in complex actions
  • handle complex cases with presets and RelationEditor

I hope these changes don't break plugins which extend or overwrite RelationEditor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java

    r17172 r17358  
    1414import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1515import org.openstreetmap.josm.tools.CheckParameterUtil;
     16import org.openstreetmap.josm.tools.Logging;
    1617
    1718/**
     
    7172     *
    7273     * @param layer the data layer the relation is a member of
    73      * @param r the relation to be edited
     74     * @param r the relation to be edited. If the relation doesn't belong to a {@code DataSet}
     75     * callers MUST NOT use the relation after calling this method.
    7476     * @param selectedMembers a collection of relation members which shall be selected when the editor is first launched
    7577     * @return an instance of RelationEditor suitable for editing that kind of relation
     
    8082        else {
    8183            RelationEditor editor = new GenericRelationEditor(layer, r, selectedMembers);
     84            if (r != null && r.getDataSet() == null) {
     85                // see #19885: We have to assume that the relation was only created as container for tags and members
     86                // the editor has created its own copy by now.
     87                // Since the members point to the container we unlink them here.
     88                Logging.debug("Member list is reset for relation  {0}", r.getUniqueId());
     89                r.setMembers(null);
     90            }
     91
    8292            RelationDialogManager.getRelationDialogManager().positionOnScreen(editor);
    8393            RelationDialogManager.getRelationDialogManager().register(layer, r, editor);
Note: See TracChangeset for help on using the changeset viewer.