summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2014-12-23 09:15:21 +0100
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-01-07 07:15:57 +0100
commitc566e7bf49a6d329f9ef6bfbee59aca8365e78ef (patch)
tree05be4749fdae7380f721be2a5839303d582a1097
parent1a1a6d0edf2d818f84606afbd6486ff0a4435b8b (diff)
downloadqtlocation-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>
-rw-r--r--src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp4
-rw-r--r--src/plugins/geoservices/osm/qgeocodereplyosm.cpp10
2 files changed, 7 insertions, 7 deletions
diff --git a/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp b/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp
index 7aaa6bd5..c4b04ece 100644
--- a/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp
@@ -71,8 +71,10 @@ QGeoCodeReplyNokia::~QGeoCodeReplyNokia()
void QGeoCodeReplyNokia::abort()
{
- if (!m_reply && !m_parsing)
+ if (!m_reply) {
+ m_parsing = false;
return;
+ }
m_reply->abort();
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;
}