Ignore:
Timestamp:
2017-11-10T22:37:58+01:00 (2 years ago)
Author:
Don-vip
Message:

fix #15538 - add robustness to AlignInLineAction

File:
1 edited

Legend:

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

    r13107 r13108  
    173173
    174174        try {
    175             MainApplication.undoRedo.add(buildCommand());
     175            Command cmd = buildCommand(getLayerManager().getEditDataSet());
     176            if (cmd != null) {
     177                MainApplication.undoRedo.add(cmd);
     178            }
    176179        } catch (InvalidSelection except) {
    177180            Logging.debug(except);
     
    184187    /**
    185188     * Builds "align in line" command depending on the selected objects.
     189     * @param ds data set in which the command operates
    186190     * @return the resulting command to execute to perform action
    187191     * @throws InvalidSelection if a polygon is selected, or if a node is used by 3 or more ways
    188      * @since 12562
    189      */
    190     public Command buildCommand() throws InvalidSelection {
    191         DataSet ds = getLayerManager().getEditDataSet();
     192     * @since 13108
     193     */
     194    public Command buildCommand(DataSet ds) throws InvalidSelection {
    192195        List<Node> selectedNodes = new ArrayList<>(ds.getSelectedNodes());
    193196        List<Way> selectedWays = new ArrayList<>(ds.getSelectedWays());
     
    276279                throw new InvalidSelection(tr("Intersection of three or more ways can not be solved. Abort."));
    277280        }
    278         return new SequenceCommand(tr("Align Nodes in Line"), cmds);
     281        return cmds.isEmpty() ? null : new SequenceCommand(tr("Align Nodes in Line"), cmds);
    279282    }
    280283
Note: See TracChangeset for help on using the changeset viewer.