Changeset 9914 in josm for trunk/src


Ignore:
Timestamp:
2016-03-02T21:29:52+01:00 (8 years ago)
Author:
Don-vip
Message:

see #12350 - fix coverity 1352420, 1352421, 1352422, 1352423, 1352424 (potential NPEs)

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r9893 r9914  
    206206                scaleList = scaleList.withIntermediateSteps(PROP_ZOOM_RATIO.get());
    207207            }
    208             Scale scale = scaleList.scaleZoomTimes(getScale(), PROP_ZOOM_RATIO.get(), times);
    209             return scale.getScale();
     208            Scale s = scaleList.scaleZoomTimes(getScale(), PROP_ZOOM_RATIO.get(), times);
     209            return s != null ? s.getScale() : 0;
    210210        } else {
    211211            return getScale() * Math.pow(PROP_ZOOM_RATIO.get(), times);
  • trunk/src/org/openstreetmap/josm/gui/layer/NativeScaleLayer.java

    r9883 r9914  
    222222        public Scale scaleZoomIn(double scale, double ratio) {
    223223            Scale snap = getSnapScale(scale, ratio, false);
    224             Scale next = getNextIn(snap, ratio);
    225             return next;
     224            return getNextIn(snap, ratio);
    226225        }
    227226
     
    234233        public Scale scaleZoomOut(double scale, double ratio) {
    235234            Scale snap = getSnapScale(scale, ratio, false);
    236             Scale next = getNextOut(snap, ratio);
    237             return next;
     235            return getNextOut(snap, ratio);
    238236        }
    239237
     
    248246
    249247        private Scale getNextIn(Scale scale, double ratio) {
     248            if (scale == null)
     249                return null;
    250250            int nextIndex = scale.getIndex() + 1;
    251251            if (nextIndex <= 0 || nextIndex > this.scales.size()-1) {
     
    258258
    259259        private Scale getNextOut(Scale scale, double ratio) {
     260            if (scale == null)
     261                return null;
    260262            int nextIndex = scale.getIndex() - 1;
    261263            if (nextIndex < 0 || nextIndex >= this.scales.size()-1) {
  • trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java

    r9860 r9914  
    6060    @Override
    6161    protected int getBestZoom() {
    62         if (!Main.isDisplayingMapView()) return 0;
     62        if (!Main.isDisplayingMapView())
     63            return 0;
     64        Scale snap = getNativeScales().getSnapScale(Main.map.mapView.getScale(), false);
    6365        return Math.max(
    6466                getMinZoomLvl(),
    6567                Math.min(
    66                         getNativeScales().getSnapScale(Main.map.mapView.getScale(), false).getIndex(),
     68                        snap != null ? snap.getIndex() : getMaxZoomLvl(),
    6769                        getMaxZoomLvl()
    6870                        )
Note: See TracChangeset for help on using the changeset viewer.