Changeset 9439 in josm


Ignore:
Timestamp:
2016-01-14T12:52:35+01:00 (8 years ago)
Author:
simon04
Message:

fix #8041 - Relation change bypassing undo system during combine way

File:
1 edited

Legend:

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

    r9371 r9439  
    124124        TagCollection wayTags = TagCollection.unionOfAllPrimitives(ways);
    125125
     126        final List<Command> reverseWayTagCommands = new LinkedList<>();
    126127        List<Way> reversedWays = new LinkedList<>();
    127128        List<Way> unreversedWays = new LinkedList<>();
     
    158159                ReverseWayTagCorrector reverseWayTagCorrector = new ReverseWayTagCorrector();
    159160                List<Way> reversedTagWays = new ArrayList<>(reversedWays.size());
    160                 Collection<Command> changePropertyCommands =  null;
    161161                for (Way w : reversedWays) {
    162162                    Way wnew = new Way(w);
    163163                    reversedTagWays.add(wnew);
    164                     changePropertyCommands = reverseWayTagCorrector.execute(w, wnew);
    165                 }
    166                 if ((changePropertyCommands != null) && !changePropertyCommands.isEmpty()) {
    167                     for (Command c : changePropertyCommands) {
    168                         c.executeCommand();
    169                     }
     164                    reverseWayTagCommands.addAll(reverseWayTagCorrector.execute(w, wnew));
     165                }
     166                if (!reverseWayTagCommands.isEmpty()) {
     167                    // commands need to be executed for CombinePrimitiveResolverDialog
     168                    Main.main.undoRedo.add(new SequenceCommand(tr("Reverse Ways"), reverseWayTagCommands));
    170169                }
    171170                wayTags = TagCollection.unionOfAllPrimitives(reversedTagWays);
     
    180179        modifiedTargetWay.setNodes(path);
    181180
    182         List<Command> resolution = CombinePrimitiveResolverDialog.launchIfNecessary(wayTags, ways, Collections.singleton(targetWay));
     181        final List<Command> resolution;
     182        try {
     183            resolution = CombinePrimitiveResolverDialog.launchIfNecessary(wayTags, ways, Collections.singleton(targetWay));
     184        } finally {
     185            if (!reverseWayTagCommands.isEmpty()) {
     186                // undo reverseWayTagCorrector and merge into SequenceCommand below
     187                Main.main.undoRedo.undo();
     188            }
     189        }
    183190
    184191        List<Command> cmds = new LinkedList<>();
     
    187194
    188195        cmds.add(new ChangeCommand(targetWay, modifiedTargetWay));
     196        cmds.addAll(reverseWayTagCommands);
    189197        cmds.addAll(resolution);
    190198        cmds.add(new DeleteCommand(deletedWays));
Note: See TracChangeset for help on using the changeset viewer.