Changeset 17063 in josm


Ignore:
Timestamp:
2020-09-27T14:55:21+02:00 (4 years ago)
Author:
GerdP
Message:

fix #19353: DataIntegrityProblemException: Relation member must be part of the same dataset as relation

  • recognize members which are not part of dataset (happens when undoing an add action)
  • remove dead code which showed popup
  • change logic which enables the refresh button (logic taken from CancelAction)
Location:
trunk/src/org/openstreetmap/josm/gui/dialogs/relation
Files:
3 edited

Legend:

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

    r16657 r17063  
    364364     */
    365365    public void applyToRelation(Relation relation) {
    366         relation.setMembers(members.stream()
    367                 .filter(rm -> !rm.getMember().isDeleted()).collect(Collectors.toList()));
     366        relation.setMembers(
     367                members.stream().filter(rm -> !rm.getMember().isDeleted() && rm.getMember().getDataSet() != null)
     368                        .collect(Collectors.toList()));
    368369    }
    369370
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/RefreshAction.java

    r15586 r17063  
    6868    @Override
    6969    public void updateEnabledState() {
    70         Relation relation = editorAccess.getEditor().getRelation();
    7170        Relation snapshot = editorAccess.getEditor().getRelationSnapshot();
    72         setEnabled(snapshot != null && (
    73             !relation.hasEqualTechnicalAttributes(snapshot) ||
    74             !relation.hasEqualSemanticAttributes(snapshot)
    75         ));
     71        setEnabled((!getMemberTableModel().hasSameMembersAs(snapshot) || getTagModel().isDirty())
     72                && !(snapshot == null && getTagModel().getTags().isEmpty()));
    7673    }
    7774
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SavingAction.java

    r16438 r17063  
    55
    66import java.awt.Component;
    7 import java.util.List;
    8 import java.util.stream.Collectors;
    97
    108import javax.swing.JOptionPane;
     
    1816import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
    1917import org.openstreetmap.josm.data.osm.Relation;
    20 import org.openstreetmap.josm.data.osm.RelationMember;
    2118import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    2219import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
     
    5148        tagEditorModel.applyToPrimitive(newRelation);
    5249        getMemberTableModel().applyToRelation(newRelation);
    53         List<RelationMember> newMembers = newRelation.getMembers().stream()
    54                 .filter(rm -> !rm.getMember().isDeleted())
    55                 .collect(Collectors.toList());
    56         if (newRelation.getMembersCount() != newMembers.size()) {
    57             newRelation.setMembers(newMembers);
    58             String msg = tr("One or more members of this new relation have been deleted while the relation editor\n" +
    59             "was open. They have been removed from the relation members list.");
    60             JOptionPane.showMessageDialog(MainApplication.getMainFrame(), msg, tr("Warning"), JOptionPane.WARNING_MESSAGE);
    61         }
    6250        // If the user wanted to create a new relation, but hasn't added any members or
    6351        // tags, don't add an empty relation
Note: See TracChangeset for help on using the changeset viewer.