Changeset 10174 in josm


Ignore:
Timestamp:
2016-05-10T16:09:21+02:00 (4 years ago)
Author:
Don-vip
Message:

fix coverity 1354674, 1354675

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

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

    r10043 r10174  
    959959                    Collections.<OsmPrimitive>emptyList(), SplitWayAction.Strategy.keepFirstChunk());
    960960
    961             //execute the command, we need the results
    962             cmds.add(split.getCommand());
    963             commitCommands(marktr("Split ways into fragments"));
    964 
    965             result.add(split.getOriginalWay());
    966             result.addAll(split.getNewWays());
    967         } else {
     961            if (split != null) {
     962                //execute the command, we need the results
     963                cmds.add(split.getCommand());
     964                commitCommands(marktr("Split ways into fragments"));
     965
     966                result.add(split.getOriginalWay());
     967                result.addAll(split.getNewWays());
     968            }
     969        }
     970        if (result.isEmpty()) {
    968971            //nothing to split
    969972            result.add(way);
  • trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java

    r10131 r10174  
    746746    public static SplitWayResult split(OsmDataLayer layer, Way way, List<Node> atNodes, Collection<? extends OsmPrimitive> selection) {
    747747        List<List<Node>> chunks = buildSplitChunks(way, atNodes);
    748         if (chunks == null) return null;
    749         return splitWay(layer, way, chunks, selection);
     748        return chunks != null ? splitWay(layer, way, chunks, selection) : null;
    750749    }
    751750
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r9989 r10174  
    88import java.awt.GridBagLayout;
    99import java.util.ArrayList;
     10import java.util.Arrays;
    1011import java.util.Collection;
    1112import java.util.Collections;
     
    2728import org.openstreetmap.josm.Main;
    2829import org.openstreetmap.josm.actions.SplitWayAction;
     30import org.openstreetmap.josm.actions.SplitWayAction.SplitWayResult;
    2931import org.openstreetmap.josm.data.osm.Node;
    3032import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    470472            return new ChangeCommand(ws.way, wnew);
    471473        } else {
    472             List<List<Node>> chunks = new ArrayList<>(2);
    473             chunks.add(n1);
    474             chunks.add(n2);
    475             return SplitWayAction.splitWay(layer, ws.way, chunks, Collections.<OsmPrimitive>emptyList()).getCommand();
     474            SplitWayResult split = SplitWayAction.splitWay(layer, ws.way, Arrays.asList(n1, n2), Collections.<OsmPrimitive>emptyList());
     475            return split != null ? split.getCommand() : null;
    476476        }
    477477    }
Note: See TracChangeset for help on using the changeset viewer.