Changeset 36134 in osm


Ignore:
Timestamp:
2023-09-07T18:20:01+02:00 (16 months ago)
Author:
taylor.smock
Message:

Use DeleteCommand.delete where possible and fix some potential NPEs from its usage

Location:
applications/editors/josm/plugins
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/addrinterpolation/src/org/openstreetmap/josm/plugins/AddrInterpolation/AddrInterpolationDialog.java

    r36132 r36134  
    978978
    979979    private void removeAddressInterpolationWay() {
    980 
    981         // Remove way - nodes of the way remain
    982         commandGroup.add(DeleteCommand.delete(Collections.singleton(addrInterpolationWay)));
    983 
    984         // Remove untagged nodes
    985         for (int i = 1; i < addrInterpolationWay.getNodesCount()-1; i++) {
    986             Node testNode = addrInterpolationWay.getNode(i);
    987             if (!testNode.hasKeys()) {
    988                 commandGroup.add(DeleteCommand.delete(Collections.singleton(testNode)));
    989             }
     980        final Command deleteCommand = DeleteCommand.delete(Collections.singleton(addrInterpolationWay), true);
     981        if (deleteCommand != null) {
     982            commandGroup.add(deleteCommand);
    990983        }
    991984
  • applications/editors/josm/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/Building.java

    r36132 r36134  
    487487                    addressCmds.add(new ChangeMembersCommand(r, members));
    488488                }
    489                 addressCmds.add(DeleteCommand.delete(Collections.singleton(addrNode)));
     489                final Command deleteCommand = DeleteCommand.delete(Collections.singleton(addrNode));
     490                if (deleteCommand != null) {
     491                    addressCmds.add(deleteCommand);
     492                }
    490493                if (cmdList == null) {
    491494                    Command c = new SequenceCommand(tr("Add address for building"), addressCmds);
  • applications/editors/josm/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/MergeAddrPointsAction.java

    r35669 r36134  
    3838import org.openstreetmap.josm.tools.Shortcut;
    3939
     40/**
     41 * Merge address points with a building
     42 */
    4043public class MergeAddrPointsAction extends JosmAction {
    4144
     45    /**
     46     * Merge the address point with the building
     47     */
    4248    public MergeAddrPointsAction() {
    4349        super(tr("Merge address points"), "mergeaddr",
     
    173179        }
    174180        if (!replaced.isEmpty()) {
    175             cmds.add(new DeleteCommand(replaced.stream().map(p -> p.a).collect(Collectors.toList())));
     181            final Command deleteCommand = DeleteCommand.delete(replaced.stream().map(p -> p.a).collect(Collectors.toList()));
     182            if (deleteCommand != null) {
     183                cmds.add(deleteCommand);
     184            }
    176185        }
    177186
  • applications/editors/josm/plugins/merge-overlap/src/mergeoverlap/MergeOverlapAction.java

    r36132 r36134  
    225225        }
    226226        if (!del.isEmpty()) {
    227             cmds.add(DeleteCommand.delete(del));
     227            final Command deleteCommand = DeleteCommand.delete(del);
     228            if (deleteCommand != null) {
     229                cmds.add(deleteCommand);
     230            }
    228231        }
    229232
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java

    r36132 r36134  
    174174                                candidateWay = tmp;
    175175                            }
    176                             commands.add(DeleteCommand.delete(Collections.singleton(w)));
     176                            final Command deleteCommand = DeleteCommand.delete(Collections.singleton(w));
     177                            if (deleteCommand != null) {
     178                                commands.add(deleteCommand);
     179                            }
    177180                        }
    178181                    }
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java

    r36132 r36134  
    399399        }
    400400        if (!foundOwnWay) {
    401             commands.add(DeleteCommand.delete(Collections.singleton(source)));
     401            final Command deleteCommand = DeleteCommand.delete(Collections.singleton(source));
     402            if (deleteCommand != null) {
     403                commands.add(deleteCommand);
     404            }
    402405        }
    403406        commands.addAll(relationCommands);
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitObjectAction.java

    r36130 r36134  
    257257            }
    258258            SplitWayCommand result = SplitWayCommand.splitWay(
    259                     selectedWay, wayChunks, Collections.<OsmPrimitive>emptyList());
     259                    selectedWay, wayChunks, Collections.emptyList());
    260260            if (splitWay != null) {
    261261                result.executeCommand();
    262262                Command delCmd = DeleteCommand.delete(Collections.singletonList(splitWay));
    263                 delCmd.executeCommand();
    264                 UndoRedoHandler.getInstance().add(new SplitObjectCommand(Arrays.asList(result, delCmd)), false);
     263                if (delCmd != null) {
     264                    delCmd.executeCommand();
     265                    UndoRedoHandler.getInstance().add(new SplitObjectCommand(Arrays.asList(result, delCmd)), false);
     266                } else {
     267                    UndoRedoHandler.getInstance().add(new SplitObjectCommand(Collections.singletonList(result)), false);
     268                }
    265269            } else {
    266270                UndoRedoHandler.getInstance().add(result);
     
    542546                if (wayChunks != null) {
    543547                    SplitWayCommand result = SplitWayCommand.splitWay(
    544                                     way, wayChunks, Collections.<OsmPrimitive>emptyList());
     548                                    way, wayChunks, Collections.emptyList());
    545549                    result.executeCommand(); // relation members are overwritten/broken if there are multiple unapplied splits
    546550                    splitCmds.add(result);
Note: See TracChangeset for help on using the changeset viewer.