Ignore:
Timestamp:
2010-06-19T14:21:38+02:00 (11 years ago)
Author:
stoecker
Message:

#close #4675 - patch by Upliner - error in conflict/undo handling

File:
1 edited

Legend:

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

    r3262 r3335  
    88import java.util.Collection;
    99import java.util.Collections;
     10import java.util.HashMap;
    1011import java.util.HashSet;
    1112import java.util.List;
     13import java.util.Map;
    1214import java.util.Set;
     15import java.util.Map.Entry;
    1316import java.util.logging.Logger;
    1417
     
    1922import org.openstreetmap.josm.data.osm.Node;
    2023import org.openstreetmap.josm.data.osm.OsmPrimitive;
     24import org.openstreetmap.josm.data.osm.PrimitiveData;
    2125import org.openstreetmap.josm.data.osm.Relation;
    2226import org.openstreetmap.josm.data.osm.Way;
     
    4852    private Set<OsmPrimitive> purgedPrimitives;
    4953
    50     private Set<OsmPrimitive> origVersionsOfTouchedPrimitives;
     54    private Map<OsmPrimitive,PrimitiveData> origVersionsOfTouchedPrimitives;
    5155
    5256    protected void init(Collection<OsmPrimitive> toPurge) {
    5357        this.toPurge = toPurge;
    5458        this.purgedPrimitives = new HashSet<OsmPrimitive>();
    55         this.origVersionsOfTouchedPrimitives = new HashSet<OsmPrimitive>();
     59        this.origVersionsOfTouchedPrimitives = new HashMap<OsmPrimitive,PrimitiveData>();
    5660    }
    5761
     
    149153            if (parent instanceof Way) {
    150154                Way w = (Way)parent;
    151                 if (!origVersionsOfTouchedPrimitives.contains(w)) {
    152                     origVersionsOfTouchedPrimitives.add(w);
     155                if (!origVersionsOfTouchedPrimitives.containsKey(w)) {
     156                    origVersionsOfTouchedPrimitives.put(w,w.save());
    153157                }
    154158                w.removeNode((Node)child);
     
    163167            } else if (parent instanceof Relation) {
    164168                Relation r = (Relation)parent;
    165                 if (!origVersionsOfTouchedPrimitives.contains(r)) {
    166                     origVersionsOfTouchedPrimitives.add(r);
     169                if (!origVersionsOfTouchedPrimitives.containsKey(r)) {
     170                    origVersionsOfTouchedPrimitives.put(r,r.save());
    167171                }
    168172                System.out.println(tr("Removing reference from relation {0}",r.getId()));
     
    200204    public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
    201205            Collection<OsmPrimitive> added) {
    202         modified.addAll(origVersionsOfTouchedPrimitives);
    203206    }
    204207
     
    219222            getLayer().data.addPrimitive(purged);
    220223        }
     224
     225        for (Entry<OsmPrimitive, PrimitiveData> entry: origVersionsOfTouchedPrimitives.entrySet()) {
     226            entry.getKey().load(entry.getValue());
     227        }
     228
    221229        reconstituteConflicts();
    222230
Note: See TracChangeset for help on using the changeset viewer.