Ticket #24703: 24703.patch

File 24703.patch, 2.5 KB (added by GerdP, 26 hours ago)
  • src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

     
    878878     * @param e the mouse event causing the action (mouse released)
    879879     */
    880880    private void confirmOrUndoMovement(MouseEvent e) {
     881        final Command lastCommand = UndoRedoHandler.getInstance().getLastCommand();
     882        if (lastCommand == null) {
     883            Logging.warn("No command found in undo/redo history, skipping confirmOrUndoMovement");
     884            return;
     885        }
     886
    881887        if (movesHiddenWay()) {
    882888            final ConfirmMoveDialog ed = new ConfirmMoveDialog();
    883889            ed.setContent(tr("Are you sure that you want to move elements with attached ways that are hidden by filters?"));
     
    884890            ed.toggleEnable("movedHiddenElements");
    885891            showConfirmMoveDialog(ed);
    886892        }
     893        // check if move was cancelled
     894        if (UndoRedoHandler.getInstance().getLastCommand() != lastCommand)
     895            return;
    887896
    888         final Command lastCommand = UndoRedoHandler.getInstance().getLastCommand();
    889         if (lastCommand == null) {
    890             Logging.warn("No command found in undo/redo history, skipping confirmOrUndoMovement");
     897        SelectAction.checkForDangerousMove(lastCommand);
     898
     899        // check if move was cancelled
     900        if (UndoRedoHandler.getInstance().getLastCommand() != lastCommand)
    891901            return;
    892         }
    893902
    894903        SelectAction.checkCommandForLargeDistance(lastCommand);
    895904
     
    915924        }
    916925    }
    917926
     927    private static void checkForDangerousMove(Command lastCommand) {
     928        if (lastCommand == null) {
     929            return;
     930        }
     931        if (!checkAndConfirmOutlyingOperation("movenode", tr("Move confirmation"),
     932                tr("You are about to move nodes that may have referrers that are not yet downloaded.")
     933                        + "<br/>"
     934                        + tr("This can lead to malformed geometries.") + "<br/>"
     935                        + tr("Do you really want to move?"),
     936                "",
     937                lastCommand.getParticipatingPrimitives(), null)) {
     938            UndoRedoHandler.getInstance().undo();
     939        }
     940    }
     941
    918942    static void checkCommandForLargeDistance(Command lastCommand) {
    919943        if (lastCommand == null) {
    920944            return;