Changeset 17240 in josm for trunk/src/org


Ignore:
Timestamp:
2020-10-19T10:56:31+02:00 (4 years ago)
Author:
GerdP
Message:

fix #14620: DataIntegrityProblemException: Deleted node referenced while using conflation
The plugin shows an error in the core class AddPrimitivesCommand.

  • AddPrimitivesCommand undo crashes with existing data with status "deleted" Patch by Tyndare, modified
  • add stability for primitives with the same unique id but different types, like a way and a node with the same id.
  • add unit tests for both
File:
1 edited

Legend:

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

    r16436 r17240  
    100100            // a subsequent command (e.g. MoveCommand) cannot be redone.
    101101            for (OsmPrimitive osm : createdPrimitives) {
    102                 if (preExistingData.stream().anyMatch(pd -> pd.getUniqueId() == osm.getUniqueId())) {
    103                     Optional<PrimitiveData> o = data.stream().filter(pd -> pd.getUniqueId() == osm.getUniqueId()).findAny();
     102                if (preExistingData.stream().anyMatch(pd -> pd.getPrimitiveId().equals(osm.getPrimitiveId()))) {
     103                    Optional<PrimitiveData> o = data.stream()
     104                            .filter(pd -> pd.getPrimitiveId().equals(osm.getPrimitiveId())).findAny();
    104105                    if (o.isPresent()) {
    105106                        osm.load(o.get());
     
    126127            createdPrimitives = PurgeCommand.topoSort(createdPrimitives);
    127128        }
    128         for (OsmPrimitive osm : createdPrimitives) {
    129             Optional<PrimitiveData> previous = preExistingData.stream().filter(pd -> pd.getUniqueId() == osm.getUniqueId()).findAny();
     129        // reversed order, see #14620
     130        for (int i = createdPrimitives.size() - 1; i >= 0; i--) {
     131            OsmPrimitive osm = createdPrimitives.get(i);
     132            Optional<PrimitiveData> previous = preExistingData.stream()
     133                    .filter(pd -> pd.getPrimitiveId().equals(osm.getPrimitiveId())).findAny();
    130134            if (previous.isPresent()) {
    131135                osm.load(previous.get());
Note: See TracChangeset for help on using the changeset viewer.