diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2014-12-23 09:15:21 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-01-07 07:15:57 +0100 |
commit | c566e7bf49a6d329f9ef6bfbee59aca8365e78ef (patch) | |
tree | 05be4749fdae7380f721be2a5839303d582a1097 /src/plugins/geoservices/osm | |
parent | 1a1a6d0edf2d818f84606afbd6486ff0a4435b8b (diff) | |
download | qtlocation-c566e7bf49a6d329f9ef6bfbee59aca8365e78ef.tar.gz |
Fix crash in Nokia geocoding engine if results are empty
Also improves the behavior of the OSM plugin to the same event
Task-number: QTBUG-43523
Change-Id: I26a5eb1814f51bc66ecba89534842fd74273f37a
Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
Diffstat (limited to 'src/plugins/geoservices/osm')
-rw-r--r-- | src/plugins/geoservices/osm/qgeocodereplyosm.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/plugins/geoservices/osm/qgeocodereplyosm.cpp b/src/plugins/geoservices/osm/qgeocodereplyosm.cpp index 6c880d2d..5823a179 100644 --- a/src/plugins/geoservices/osm/qgeocodereplyosm.cpp +++ b/src/plugins/geoservices/osm/qgeocodereplyosm.cpp @@ -79,6 +79,7 @@ void QGeoCodeReplyOsm::networkReplyFinished() if (m_reply->error() != QNetworkReply::NoError) return; + QList<QGeoLocation> locations; QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); if (document.isObject()) { @@ -105,16 +106,12 @@ void QGeoCodeReplyOsm::networkReplyFinished() location.setCoordinate(coordinate); location.setAddress(address); - QList<QGeoLocation> locations; locations.append(location); setLocations(locations); - setFinished(true); } else if (document.isArray()) { QJsonArray results = document.array(); - QList<QGeoLocation> locations; - for (int i = 0; i < results.count(); ++i) { if (!results.at(i).isObject()) continue; @@ -157,10 +154,11 @@ void QGeoCodeReplyOsm::networkReplyFinished() locations.append(location); } - setLocations(locations); - setFinished(true); } + setLocations(locations); + setFinished(true); + m_reply->deleteLater(); m_reply = 0; } |