Ignore:
Timestamp:
2014-02-26T23:33:44+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #6373 - proper conflict resolution after failed attempt to delete an object referenced by an unknown one

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/DeletedStateConflictResolveCommand.java

    r6881 r6886  
    55
    66import java.util.Collection;
     7import java.util.Set;
    78
    89import javax.swing.Icon;
     
    1112import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1213import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
    13 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1414import org.openstreetmap.josm.tools.ImageProvider;
    1515
    1616/**
    1717 * Represents the resolution of a conflict between the deleted flag of two {@link OsmPrimitive}s.
    18  *
     18 * @since 1654
    1919 */
    2020public class DeletedStateConflictResolveCommand extends ConflictResolveCommand {
     
    2727
    2828    /**
    29      * constructor
     29     * Constructs a new {@code DeletedStateConflictResolveCommand}.
    3030     *
    3131     * @param conflict the conflict data set
     
    4949    @Override
    5050    public boolean executeCommand() {
    51         // remember the current state of modified primitives, i.e. of
    52         // OSM primitive 'my'
    53         //
     51        // remember the current state of modified primitives, i.e. of OSM primitive 'my'
    5452        super.executeCommand();
    55 
    56         OsmDataLayer layer = getLayer();
    5753
    5854        if (decision.equals(MergeDecisionType.KEEP_MINE)) {
     
    6056                // because my was involved in a conflict it my still be referred
    6157                // to from a way or a relation. Fix this now.
    62                 //
    63                 layer.data.unlinkReferencesToPrimitive(conflict.getMy());
    64                 conflict.getMy().setDeleted(true);
     58                deleteMy();
    6559            }
    6660        } else if (decision.equals(MergeDecisionType.KEEP_THEIR)) {
    6761            if (conflict.getTheir().isDeleted()) {
    68                 layer.data.unlinkReferencesToPrimitive(conflict.getMy());
    69                 conflict.getMy().setDeleted(true);
     62                deleteMy();
    7063            } else {
    7164                conflict.getMy().setDeleted(false);
     
    7871        return true;
    7972    }
     73   
     74    private void deleteMy() {
     75        Set<OsmPrimitive> referrers = getLayer().data.unlinkReferencesToPrimitive(conflict.getMy());
     76        for (OsmPrimitive p : referrers) {
     77            if (!p.isNew() && !p.isDeleted()) {
     78                p.setModified(true);
     79            }
     80        }
     81        conflict.getMy().setDeleted(true);
     82    }
    8083
    8184    @Override
Note: See TracChangeset for help on using the changeset viewer.