Ticket #20098: 20098.patch

File 20098.patch, 941 bytes (added by GerdP, 4 years ago)

Keep undo/redo stack intact if Command.undo() throws Execption

  • src/org/openstreetmap/josm/data/UndoRedoHandler.java

     
    377377            try {
    378378                for (int i = 1; i <= num; ++i) {
    379379                    final Command c = commands.removeLast();
    380                     c.undoCommand();
     380                    try {
     381                        c.undoCommand();
     382                    } catch (Exception e) { // NOPMD
     383                        // fix #20098: restore command stack as we will not fire an event
     384                        commands.add(c);
     385                        throw e;
     386                    }
    381387                    redoCommands.addFirst(c);
    382388                    fireEvent(new CommandUndoneEvent(this, c));
    383389                    if (commands.isEmpty()) {