Ignore:
Timestamp:
2012-06-24T21:02:36+02:00 (8 years ago)
Author:
Don-vip
Message:

see #4899, see #7266, see #7333: Resolved NPE in conflict manager when copying a member created by merging two layers

Location:
trunk/src/org/openstreetmap/josm/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/conflict/Conflict.java

    r5266 r5298  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.conflict;
     3
     4import java.util.Map;
    35
    46import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2224    private final T their;
    2325    private final boolean isMyDeleted;
     26   
     27    // mergedMap is only set if the conflict results from merging two layers
     28    private Map<PrimitiveId, PrimitiveId> mergedMap;
    2429
    2530    public Conflict(T my, T their) {
     
    111116        return isMyDeleted;
    112117    }
     118
     119    public final Map<PrimitiveId, PrimitiveId> getMergedMap() {
     120        return mergedMap;
     121    }
     122
     123    public final void setMergedMap(Map<PrimitiveId, PrimitiveId> mergedMap) {
     124        this.mergedMap = mergedMap;
     125    }
    113126}
  • trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java

    r5266 r5298  
    134134            return null;
    135135        return targetDataSet.getPrimitiveById(targetId);
     136    }
     137   
     138    protected void addConflict(Conflict<?> c) {
     139        c.setMergedMap(mergedMap);
     140        conflicts.add(c);
     141    }
     142
     143    protected void addConflict(OsmPrimitive my, OsmPrimitive their) {
     144        addConflict(new Conflict<OsmPrimitive>(my, their));
    136145    }
    137146
     
    188197                        // add a conflict and don't delete the object
    189198                        if (!objectsToDelete.contains(referrer)) {
    190                             conflicts.add(target, source);
     199                            addConflict(target, source);
    191200                            it.remove();
    192201                            flag = true;
     
    235244                newNodes.add(targetNode);
    236245                if (targetNode.isDeleted() && !conflicts.hasConflictForMy(targetNode)) {
    237                     conflicts.add(new Conflict<OsmPrimitive>(targetNode, sourceNode, true));
     246                    addConflict(new Conflict<OsmPrimitive>(targetNode, sourceNode, true));
    238247                    targetNode.setDeleted(false);
    239248                }
     
    263272            newMembers.add(newMember);
    264273            if (targetMember.isDeleted() && !conflicts.hasConflictForMy(targetMember)) {
    265                 conflicts.add(new Conflict<OsmPrimitive>(targetMember, sourceMember.getMember(), true));
     274                addConflict(new Conflict<OsmPrimitive>(targetMember, sourceMember.getMember(), true));
    266275                targetMember.setDeleted(false);
    267276            }
     
    317326            for (OsmPrimitive referrer: source.getReferrers()) {
    318327                if (targetDataSet.getPrimitiveById(referrer.getPrimitiveId()) == null) {
    319                     conflicts.add(new Conflict<OsmPrimitive>(target, source, true));
     328                    addConflict(new Conflict<OsmPrimitive>(target, source, true));
    320329                    target.setDeleted(false);
    321330                    break;
     
    352361            // this have to be resolved manually.
    353362            //
    354             conflicts.add(target,source);
     363            addConflict(target,source);
    355364        } else if (! target.hasEqualSemanticAttributes(source)) {
    356365            // target is modified and is not semantically equal with source. Can't automatically
    357366            // resolve the differences
    358367            // =>  create a conflict
    359             conflicts.add(target,source);
     368            addConflict(target,source);
    360369        } else {
    361370            // clone from other. mergeFrom will mainly copy
Note: See TracChangeset for help on using the changeset viewer.