Changeset 7921 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2015-01-03T15:37:32+01:00 (5 years ago)
Author:
Don-vip
Message:

fix #10921 - NPE

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

Legend:

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

    r7828 r7921  
    55import java.util.ArrayList;
    66import java.util.Collection;
     7import java.util.Collections;
    78import java.util.TreeMap;
    89
     
    1011import org.openstreetmap.josm.data.coor.EastNorth;
    1112import org.openstreetmap.josm.data.osm.BBox;
     13import org.openstreetmap.josm.data.osm.DataSet;
    1214import org.openstreetmap.josm.data.osm.Node;
    1315import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    3032     */
    3133    public static Collection<OsmPrimitive> getSurroundingObjects(EastNorth internalPoint) {
     34        final DataSet ds = getCurrentDataSet();
     35        if (ds == null) {
     36            return Collections.emptySet();
     37        }
    3238        final Node n = new Node(internalPoint);
    3339        final TreeMap<Double, OsmPrimitive> found = new TreeMap<>();
    34         for (Way w : getCurrentDataSet().getWays()) {
     40        for (Way w : ds.getWays()) {
    3541            if (w.isUsable() && w.isClosed()) {
    3642                if (Geometry.nodeInsidePolygon(n, w.getNodes())) {
     
    3945            }
    4046        }
    41         for (Relation r : getCurrentDataSet().getRelations()) {
     47        for (Relation r : ds.getRelations()) {
    4248            if (r.isUsable() && r.isMultipolygon()) {
    4349                if (Geometry.isNodeInsideMultiPolygon(n, r, null)) {
  • trunk/src/org/openstreetmap/josm/gui/SelectionManager.java

    r7146 r7921  
    151151    @Override
    152152    public void mousePressed(MouseEvent e) {
    153         if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1) {
     153        if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1 && Main.main.getCurrentDataSet() != null) {
    154154            SelectByInternalPointAction.performSelection(Main.map.mapView.getEastNorth(e.getX(), e.getY()),
    155155                    (e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) > 0,
Note: See TracChangeset for help on using the changeset viewer.