Changeset 12550 in josm


Ignore:
Timestamp:
2017-08-01T00:59:21+02:00 (4 months ago)
Author:
Don-vip
Message:

sonar - squid:S2259 - Null pointers should not be dereferenced

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

Legend:

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

    r11553 r12550  
    8787
    8888        Node targetNode = selectTargetNode(selectedNodes);
    89         Node targetLocationNode = selectTargetLocationNode(selectedNodes);
    90         Command cmd = mergeNodes(Main.getLayerManager().getEditLayer(), selectedNodes, targetNode, targetLocationNode);
    91         if (cmd != null) {
    92             Main.main.undoRedo.add(cmd);
    93             Main.getLayerManager().getEditLayer().data.setSelected(targetNode);
     89        if (targetNode != null) {
     90            Node targetLocationNode = selectTargetLocationNode(selectedNodes);
     91            Command cmd = mergeNodes(Main.getLayerManager().getEditLayer(), selectedNodes, targetNode, targetLocationNode);
     92            if (cmd != null) {
     93                Main.main.undoRedo.add(cmd);
     94                Main.getLayerManager().getEditLayer().data.setSelected(targetNode);
     95            }
    9496        }
    9597    }
     
    265267        }
    266268
    267         Command cmd = mergeNodes(layer, nodes, target, targetLocationNode);
    268         if (cmd != null) {
    269             Main.main.undoRedo.add(cmd);
    270             layer.data.setSelected(target);
     269        if (target != null) {
     270            Command cmd = mergeNodes(layer, nodes, target, targetLocationNode);
     271            if (cmd != null) {
     272                Main.main.undoRedo.add(cmd);
     273                layer.data.setSelected(target);
     274            }
    271275        }
    272276    }
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r12279 r12550  
    684684            } // else: keep currentLayer and tileProjection as is
    685685        }
    686         this.currentTileMatrixSet = this.currentLayer.tileMatrixSet;
    687         Collection<Double> scales = new ArrayList<>(currentTileMatrixSet.tileMatrix.size());
    688         for (TileMatrix tileMatrix : currentTileMatrixSet.tileMatrix) {
    689             scales.add(tileMatrix.scaleDenominator * 0.28e-03);
    690         }
    691         this.nativeScaleList = new ScaleList(scales);
     686        if (this.currentLayer != null) {
     687            this.currentTileMatrixSet = this.currentLayer.tileMatrixSet;
     688            Collection<Double> scales = new ArrayList<>(currentTileMatrixSet.tileMatrix.size());
     689            for (TileMatrix tileMatrix : currentTileMatrixSet.tileMatrix) {
     690                scales.add(tileMatrix.scaleDenominator * 0.28e-03);
     691            }
     692            this.nativeScaleList = new ScaleList(scales);
     693        }
    692694        this.crsScale = getTileSize() * 0.28e-03 / this.tileProjection.getMetersPerUnit();
    693695    }
Note: See TracChangeset for help on using the changeset viewer.