Ignore:
Timestamp:
2016-12-14T15:50:53+01:00 (7 years ago)
Author:
Don-vip
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r11383 r11397  
    504504                        if (e.hasThumbnail()) {
    505505                            Dimension d = scaledDimension(e.getThumbnail());
    506                             Rectangle target = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height);
    507                             if (clip.intersects(target)) {
    508                                 tempG.drawImage(e.getThumbnail(), target.x, target.y, target.width, target.height, null);
     506                            if (d != null) {
     507                                Rectangle target = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height);
     508                                if (clip.intersects(target)) {
     509                                    tempG.drawImage(e.getThumbnail(), target.x, target.y, target.width, target.height, null);
     510                                }
    509511                            }
    510512                        } else { // thumbnail not loaded yet
     
    540542                if (useThumbs && e.hasThumbnail()) {
    541543                    Dimension d = scaledDimension(e.getThumbnail());
    542                     imgWidth = d.width;
    543                     imgHeight = d.height;
     544                    if (d != null) {
     545                        imgWidth = d.width;
     546                        imgHeight = d.height;
     547                    } else {
     548                        imgWidth = -1;
     549                        imgHeight = -1;
     550                    }
    544551                } else {
    545552                    imgWidth = selectedIcon.getIconWidth();
     
    756763                if (useThumbs && img.hasThumbnail()) {
    757764                    Dimension d = scaledDimension(img.getThumbnail());
    758                     r = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height);
     765                    if (d != null)
     766                        r = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height);
     767                    else
     768                        r = null;
    759769                } else {
    760770                    r = new Rectangle(p.x - icon.getIconWidth() / 2,
     
    763773                                      icon.getIconHeight());
    764774                }
    765                 if (r.contains(evt.getPoint())) {
     775                if (r != null && r.contains(evt.getPoint())) {
    766776                    return img;
    767777                }
     
    861871                    if (useThumbs && e.hasThumbnail()) {
    862872                        Dimension d = scaledDimension(e.getThumbnail());
    863                         r = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height);
     873                        if (d != null)
     874                            r = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height);
     875                        else
     876                            r = null;
    864877                    } else {
    865878                        r = new Rectangle(p.x - icon.getIconWidth() / 2,
     
    868881                                icon.getIconHeight());
    869882                    }
    870                     if (r.contains(ev.getPoint())) {
     883                    if (r != null && r.contains(ev.getPoint())) {
    871884                        clearOtherCurrentPhotos();
    872885                        currentPhoto = i;
Note: See TracChangeset for help on using the changeset viewer.