Changeset 8660 in josm for trunk/src/org


Ignore:
Timestamp:
2015-08-12T23:30:18+02:00 (9 years ago)
Author:
Don-vip
Message:

fix #11756 - NPEs

Location:
trunk/src/org/openstreetmap/josm/gui/layer/geoimage
Files:
2 edited

Legend:

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

    r8658 r8660  
    451451                @Override
    452452                public int getSize() {
    453                     return yLayer.data.size();
     453                    return yLayer.data != null ? yLayer.data.size() : 0;
    454454                }
    455455            });
     
    824824            // The selection of images we are about to correlate may have changed.
    825825            // So reset all images.
    826             for (ImageEntry ie: yLayer.data) {
    827                 ie.tmp = null;
     826            if (yLayer.data != null) {
     827                for (ImageEntry ie: yLayer.data) {
     828                    ie.tmp = null;
     829                }
    828830            }
    829831
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r8658 r8660  
    367367        int tagged = 0;
    368368        int newdata = 0;
    369         for (ImageEntry e : data) {
    370             if (e.getPos() != null) {
    371                 tagged++;
    372             }
    373             if (e.hasNewGpsData()) {
    374                 newdata++;
     369        int n = 0;
     370        if (data != null) {
     371            n = data.size();
     372            for (ImageEntry e : data) {
     373                if (e.getPos() != null) {
     374                    tagged++;
     375                }
     376                if (e.hasNewGpsData()) {
     377                    newdata++;
     378                }
    375379            }
    376380        }
    377381        return "<html>"
    378                 + trn("{0} image loaded.", "{0} images loaded.", data.size(), data.size())
     382                + trn("{0} image loaded.", "{0} images loaded.", n, n)
    379383                + " " + trn("{0} was found to be GPS tagged.", "{0} were found to be GPS tagged.", tagged, tagged)
    380384                + (newdata > 0 ? "<br>" + trn("{0} has updated GPS data.", "{0} have updated GPS data.", newdata, newdata) : "")
     
    405409        l.stopLoadThumbs();
    406410
    407         final ImageEntry selected = l.currentPhoto >= 0 ? l.data.get(l.currentPhoto) : null;
    408 
    409         data.addAll(l.data);
     411        final ImageEntry selected = l.data != null && l.currentPhoto >= 0 ? l.data.get(l.currentPhoto) : null;
     412
     413        if (l.data != null) {
     414            data.addAll(l.data);
     415        }
    410416        Collections.sort(data);
    411417
     
    492498                tempG.setComposite(saveComp);
    493499
    494                 for (ImageEntry e : data) {
    495                     if (e.getPos() == null) {
    496                         continue;
     500                if (data != null) {
     501                    for (ImageEntry e : data) {
     502                        if (e.getPos() == null) {
     503                            continue;
     504                        }
     505                        Point p = mv.getPoint(e.getPos());
     506                        if (e.thumbnail != null) {
     507                            Dimension d = scaledDimension(e.thumbnail);
     508                            Rectangle target = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height);
     509                            if (clip.intersects(target)) {
     510                                tempG.drawImage(e.thumbnail, target.x, target.y, target.width, target.height, null);
     511                            }
     512                        } else { // thumbnail not loaded yet
     513                            icon.paintIcon(mv, tempG,
     514                                    p.x - icon.getIconWidth() / 2,
     515                                    p.y - icon.getIconHeight() / 2);
     516                        }
    497517                    }
    498                     Point p = mv.getPoint(e.getPos());
    499                     if (e.thumbnail != null) {
    500                         Dimension d = scaledDimension(e.thumbnail);
    501                         Rectangle target = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height);
    502                         if (clip.intersects(target)) {
    503                             tempG.drawImage(e.thumbnail, target.x, target.y, target.width, target.height, null);
    504                         }
    505                     } else { // thumbnail not loaded yet
    506                         icon.paintIcon(mv, tempG,
    507                                 p.x - icon.getIconWidth() / 2,
    508                                 p.y - icon.getIconHeight() / 2);
    509                     }
    510518                }
    511519                updateOffscreenBuffer = false;
    512520            }
    513521            g.drawImage(offscreenBuffer, 0, 0, null);
    514         } else {
     522        } else if (data != null) {
    515523            for (ImageEntry e : data) {
    516524                if (e.getPos() == null) {
     
    10221030                    MapFrame.removeMapModeChangeListener(mapModeListener);
    10231031                    currentPhoto = -1;
    1024                     data.clear();
     1032                    if (data != null) {
     1033                        data.clear();
     1034                    }
    10251035                    data = null;
    10261036                    // stop listening to layer change events
Note: See TracChangeset for help on using the changeset viewer.