Ignore:
Timestamp:
2020-06-16T10:27:46+02:00 (6 years ago)
Author:
GerdP
Message:

fix #19312: detect circular dependencies in relations

  • add test in RelationChecker to detect them
  • show popup when user is about to create one and refuse the action

I am not happy with the texts but such a rather complex problem probably requires a complex message :(

File:
1 edited

Legend:

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

    r14030 r16651  
    88import org.openstreetmap.josm.data.osm.OsmPrimitive;
    99import org.openstreetmap.josm.data.osm.Relation;
     10import org.openstreetmap.josm.data.validation.tests.RelationChecker;
    1011import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
    1112import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor;
     
    3435        ConditionalOptionPaneUtil.startBulkOperation("add_primitive_to_relation");
    3536        for (OsmPrimitive primitive : primitives) {
    36             if (primitive instanceof Relation
    37                     && editorAccess.getEditor().getRelation() != null && editorAccess.getEditor().getRelation().equals(primitive)) {
    38                 GenericRelationEditor.warnOfCircularReferences(primitive);
    39                 continue;
     37            if (primitive instanceof Relation) {
     38                List<Relation> loop = RelationChecker.checkAddMember(editorAccess.getEditor().getRelation(), (Relation) primitive);
     39                if (!loop.isEmpty() && loop.get(0).equals(loop.get(loop.size() - 1))) {
     40                    GenericRelationEditor.warnOfCircularReferences(primitive, loop);
     41                    continue;
     42                }
    4043            }
    4144            if (isPotentialDuplicate(primitive)) {
Note: See TracChangeset for help on using the changeset viewer.