diff options
author | Wolfgang Bremer <wbremer@blackberry.com> | 2014-08-08 15:07:18 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-08-11 10:36:19 +0200 |
commit | 0c9e7372d91260229c877497a349f0a5994f21c9 (patch) | |
tree | d64342a9602983111908a4fb852de7bc4ca4d002 | |
parent | d771c5dd31b46d76a8b9b9043263b754df81467d (diff) | |
download | qtlocation-0c9e7372d91260229c877497a349f0a5994f21c9.tar.gz |
Fix QGeoRouteReplyOsm::networkReplyFinished
It can happen that the osm router does not find a route between the
specified points. In this case it returns a json object with a status
code other than 0 and an error message.
This commit notifies the app developer that an error occurred and
that no valid route is available.
Prior this it was not possible to catch the error message.
Change-Id: I172ae3cf9dfcd80e5a162110178203084071c9b0
Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r-- | src/plugins/geoservices/osm/qgeoroutereplyosm.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp index 9f71c0b1..c15bb48f 100644 --- a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp +++ b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp @@ -348,8 +348,17 @@ void QGeoRouteReplyOsm::networkReplyFinished() QJsonObject object = document.object(); //double version = object.value(QStringLiteral("version")).toDouble(); - //int status = object.value(QStringLiteral("status")).toDouble(); - //QString statusMessage = object.value(QStringLiteral("status_message")).toString(); + int status = object.value(QStringLiteral("status")).toDouble(); + QString statusMessage = object.value(QStringLiteral("status_message")).toString(); + + // status code is 0 in case of success + // status code is 207 if no route was found + // an error occurred when trying to find a route + if (0 != status) { + setError(QGeoRouteReply::UnknownError, statusMessage); + m_reply->deleteLater(); + return; + } QJsonObject routeSummary = object.value(QStringLiteral("route_summary")).toObject(); |