Changeset 19014 in josm for trunk/test


Ignore:
Timestamp:
2024-03-08T10:58:03+01:00 (7 months ago)
Author:
GerdP
Message:

fix #23527: Memory leak in relation editor

  • add new method wouldRelationBeUseful() in IRelationEditorActionAccess which doesn't call the problematic method getChangedRelation() to evaluate whether a relation would be useful if saved.
  • add comments and code in unit test for the method that shows how to handle the result of getChangedRelation() in case it is not needed any longer to avoid the memory leak.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/RelationEditorActionsTest.java

    r18433 r19014  
    1717import org.openstreetmap.josm.data.coor.LatLon;
    1818import org.openstreetmap.josm.data.osm.DataSet;
     19import org.openstreetmap.josm.data.osm.IRelation;
    1920import org.openstreetmap.josm.data.osm.Node;
    2021import org.openstreetmap.josm.data.osm.Relation;
     
    169170        relationEditorAccess.getTagModel().initFromPrimitive(relation);
    170171        relationEditorAccess.getEditor().reloadDataFromRelation();
    171         assertDoesNotThrow(relationEditorAccess::getChangedRelation);
     172
     173        assertDoesNotThrow(() -> {
     174            IRelation<?> tempRelation = relationEditorAccess.getChangedRelation();
     175            if (tempRelation.getDataSet() == null)
     176                tempRelation.setMembers(null); // see #19885
     177        });
    172178    }
    173179}
Note: See TracChangeset for help on using the changeset viewer.