Ignore:
Timestamp:
2016-11-13T14:49:39+01:00 (9 years ago)
Author:
Don-vip
Message:

see #10387 - refactor actions to fix taginfo script

File:
1 edited

Legend:

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

    r11240 r11252  
    760760            return;
    761761        case 1:
    762             Main.main.undoRedo.add(cmds.getFirst());
     762            commitCommand(cmds.getFirst());
    763763            break;
    764764        default:
    765             Command c = new SequenceCommand(tr(description), cmds);
    766             Main.main.undoRedo.add(c);
     765            commitCommand(new SequenceCommand(tr(description), cmds));
    767766            break;
    768767        }
     
    770769        cmds.clear();
    771770        cmdsCount++;
     771    }
     772
     773    private static void commitCommand(Command c) {
     774        if (Main.main != null) {
     775            Main.main.undoRedo.add(c);
     776        } else {
     777            c.executeCommand();
     778        }
    772779    }
    773780
     
    12791286            if (!way.insideToTheRight) {
    12801287                ReverseWayResult res = ReverseWayAction.reverseWay(way.way);
    1281                 Main.main.undoRedo.add(res.getReverseCommand());
     1288                commitCommand(res.getReverseCommand());
    12821289                cmdsCount++;
    12831290            }
     
    12861293        Pair<Way, Command> result = CombineWayAction.combineWaysWorker(actionWays);
    12871294
    1288         Main.main.undoRedo.add(result.b);
     1295        commitCommand(result.b);
    12891296        cmdsCount++;
    12901297
     
    15361543     */
    15371544    private void makeCommitsOneAction(String message) {
    1538         UndoRedoHandler ur = Main.main.undoRedo;
    15391545        cmds.clear();
    1540         int i = Math.max(ur.commands.size() - cmdsCount, 0);
    1541         for (; i < ur.commands.size(); i++) {
    1542             cmds.add(ur.commands.get(i));
    1543         }
    1544 
    1545         for (i = 0; i < cmds.size(); i++) {
    1546             ur.undo();
     1546        if (Main.main != null) {
     1547            UndoRedoHandler ur = Main.main.undoRedo;
     1548            int i = Math.max(ur.commands.size() - cmdsCount, 0);
     1549            for (; i < ur.commands.size(); i++) {
     1550                cmds.add(ur.commands.get(i));
     1551            }
     1552
     1553            for (i = 0; i < cmds.size(); i++) {
     1554                ur.undo();
     1555            }
    15471556        }
    15481557
Note: See TracChangeset for help on using the changeset viewer.