diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2014-01-17 22:06:17 +0100 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2014-01-17 22:06:17 +0100 |
| commit | d8cca2b5580f57655c707c98680cf00677e78165 (patch) | |
| tree | eb1505519c3ee987e1476e30fa4f283502649850 | |
| parent | e210da6c0ac577ea1e0c4301a9aba3cf78cf06a7 (diff) | |
| download | cgeo-d8cca2b5580f57655c707c98680cf00677e78165.zip cgeo-d8cca2b5580f57655c707c98680cf00677e78165.tar.gz cgeo-d8cca2b5580f57655c707c98680cf00677e78165.tar.bz2 | |
fix #3549: NPE when exporting invalid cache
| -rw-r--r-- | main/src/cgeo/geocaching/export/GpxSerializer.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/export/GpxSerializer.java b/main/src/cgeo/geocaching/export/GpxSerializer.java index ecc687f..2afed44 100644 --- a/main/src/cgeo/geocaching/export/GpxSerializer.java +++ b/main/src/cgeo/geocaching/export/GpxSerializer.java @@ -90,9 +90,14 @@ public final class GpxSerializer { private void exportBatch(final XmlSerializer gpx, Collection<String> geocodesOfBatch) throws IOException { final Set<Geocache> caches = DataStore.loadCaches(geocodesOfBatch, LoadFlags.LOAD_ALL_DB_ONLY); for (final Geocache cache : caches) { + final Geopoint coords = cache != null ? cache.getCoords() : null; + if (coords == null) { + // Export would be invalid without coordinates. + continue; + } gpx.startTag(PREFIX_GPX, "wpt"); - gpx.attribute("", "lat", Double.toString(cache.getCoords().getLatitude())); - gpx.attribute("", "lon", Double.toString(cache.getCoords().getLongitude())); + gpx.attribute("", "lat", Double.toString(coords.getLatitude())); + gpx.attribute("", "lon", Double.toString(coords.getLongitude())); final Date hiddenDate = cache.getHiddenDate(); if (hiddenDate != null) { |
