Ticket #19885: 19885-rel-editor.patch

File 19885-rel-editor.patch, 2.0 KB (added by GerdP, 5 years ago)

RFC: let RelationEditor clean up

  • src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java

     
    1313import org.openstreetmap.josm.gui.MainApplication;
    1414import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1515import org.openstreetmap.josm.tools.CheckParameterUtil;
     16import org.openstreetmap.josm.tools.Logging;
    1617
    1718/**
    1819 * Abstract relation editor.
     
    7071     * This method is guaranteed to return a working RelationEditor.
    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
    7678     */
     
    7981            return RelationDialogManager.getRelationDialogManager().getEditorForRelation(layer, r);
    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);
    8494            return editor;