Ticket #23477: 23477.patch
| File 23477.patch, 3.3 KB (added by , 2 years ago) |
|---|
-
src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
38 38 import org.openstreetmap.josm.data.UndoRedoHandler; 39 39 import org.openstreetmap.josm.data.coor.EastNorth; 40 40 import org.openstreetmap.josm.data.coor.ILatLon; 41 import org.openstreetmap.josm.data.osm.DataIntegrityProblemException;42 41 import org.openstreetmap.josm.data.osm.DataSet; 43 42 import org.openstreetmap.josm.data.osm.Node; 44 43 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 81 80 private long mouseDownTime; 82 81 private transient WaySegment selectedSegment; 83 82 private transient Node selectedNode; 83 private transient Command lastCommandOnUndoStack; 84 84 private Color mainColor; 85 85 private transient Stroke mainStroke; 86 86 … … 331 331 map.keyDetector.removeModifierExListener(this); 332 332 this.selectedNode = null; 333 333 this.selectedSegment = null; 334 this.lastCommandOnUndoStack = null; 334 335 super.exitMode(); 335 336 } 336 337 … … 401 402 402 403 // If nothing gets caught, stay in select mode 403 404 if (selectedSegment == null && selectedNode == null) return; 405 lastCommandOnUndoStack = UndoRedoHandler.getInstance().getLastCommand(); 404 406 405 407 if (selectedNode != null) { 406 408 if (ctrl || nodeDragWithoutCtrl) { … … 545 547 // double click adds a new node 546 548 addNewNode(e); 547 549 } else if (e.getPoint().distance(initialMousePos) > initialMoveThreshold && newN1en != null && selectedSegment != null) { 548 try { 549 // main extrusion commands 550 performExtrusion(); 551 } catch (DataIntegrityProblemException ex) { 552 // Can occur if calling undo while extruding, see #12870 553 Logging.error(ex); 554 } 550 // main extrusion commands 551 performExtrusion(); 555 552 } 556 553 } else if (mode == Mode.translate || mode == Mode.translate_node) { 557 554 //Commit translate … … 566 563 mapView.setNewCursor(ctrl ? cursorTranslate : alt ? cursorCreateNew : shift ? cursorCreateNodes : cursor, this); 567 564 mapView.removeTemporaryLayer(this); 568 565 selectedSegment = null; 566 lastCommandOnUndoStack = null; 569 567 moveCommand = null; 570 568 mode = Mode.select; 571 569 dualAlignSegmentCollapsed = false; … … 638 636 * Uses {@link #newN1en}, {@link #newN2en} calculated by {@link #calculateBestMovementAndNewNodes} 639 637 */ 640 638 private void performExtrusion() { 639 // sanity checks, see #23447 and #12870: don't try to extrude when user press undo 640 if (lastCommandOnUndoStack != UndoRedoHandler.getInstance().getLastCommand()) 641 return; 641 642 DataSet ds = getLayerManager().getEditDataSet(); 643 if (ds.getPrimitiveById(selectedSegment.getWay()) == null || !selectedSegment.isUsable()) 644 return; 645 642 646 // create extrusion 643 647 Collection<Command> cmds = new LinkedList<>(); 644 648 Way wnew = new Way(selectedSegment.getWay());
