Changeset 15050 in josm


Ignore:
Timestamp:
2019-05-05T17:10:34+02:00 (7 months ago)
Author:
Don-vip
Message:

fix #16904 - make ImproveWayAccuracy aware of primitives deletion to ensure consistency (avoids DataIntegrityProblemException seen on macOS when using undo)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java

    r14960 r15050  
    3838import org.openstreetmap.josm.data.osm.Way;
    3939import org.openstreetmap.josm.data.osm.WaySegment;
     40import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent;
     41import org.openstreetmap.josm.data.osm.event.DataChangedEvent;
     42import org.openstreetmap.josm.data.osm.event.DataSetListener;
     43import org.openstreetmap.josm.data.osm.event.DatasetEventManager;
     44import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
     45import org.openstreetmap.josm.data.osm.event.NodeMovedEvent;
     46import org.openstreetmap.josm.data.osm.event.PrimitivesAddedEvent;
     47import org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent;
     48import org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent;
    4049import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
     50import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
     51import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
    4152import org.openstreetmap.josm.data.preferences.CachingProperty;
    4253import org.openstreetmap.josm.data.preferences.IntegerProperty;
     
    6273 * @author Alexander Kachkaev <alexander@kachkaev.ru>, 2011
    6374 */
    64 public class ImproveWayAccuracyAction extends MapMode implements DataSelectionListener, ModifierExListener {
     75public class ImproveWayAccuracyAction extends MapMode implements DataSelectionListener, DataSetListener, ModifierExListener {
    6576
    6677    private static final String CROSSHAIR = /* ICON(cursor/)*/ "crosshair";
     
    157168        map.mapView.addTemporaryLayer(temporaryLayer);
    158169        SelectionEventManager.getInstance().addSelectionListener(this);
     170        DatasetEventManager.getInstance().addDatasetListener(this, FireMode.IMMEDIATELY);
    159171
    160172        map.keyDetector.addModifierExListener(this);
     
    175187        map.mapView.removeTemporaryLayer(temporaryLayer);
    176188        SelectionEventManager.getInstance().removeSelectionListener(this);
     189        DatasetEventManager.getInstance().removeDatasetListener(this);
    177190
    178191        map.keyDetector.removeModifierExListener(this);
     
    659672        startSelecting();
    660673    }
     674
     675    @Override
     676    public void primitivesRemoved(PrimitivesRemovedEvent event) {
     677        if (event.getPrimitives().contains(candidateNode) || event.getPrimitives().contains(targetWay)) {
     678            updateCursorDependentObjectsIfNeeded();
     679        }
     680    }
     681
     682    @Override
     683    public void primitivesAdded(PrimitivesAddedEvent event) {
     684        // Do nothing
     685    }
     686
     687    @Override
     688    public void tagsChanged(TagsChangedEvent event) {
     689        // Do nothing
     690    }
     691
     692    @Override
     693    public void nodeMoved(NodeMovedEvent event) {
     694        // Do nothing
     695    }
     696
     697    @Override
     698    public void wayNodesChanged(WayNodesChangedEvent event) {
     699        // Do nothing
     700    }
     701
     702    @Override
     703    public void relationMembersChanged(RelationMembersChangedEvent event) {
     704        // Do nothing
     705    }
     706
     707    @Override
     708    public void otherDatasetChange(AbstractDatasetChangedEvent event) {
     709        // Do nothing
     710    }
     711
     712    @Override
     713    public void dataChanged(DataChangedEvent event) {
     714        // Do nothing
     715    }
    661716}
Note: See TracChangeset for help on using the changeset viewer.