From 0c9e7372d91260229c877497a349f0a5994f21c9 Mon Sep 17 00:00:00 2001 From: Wolfgang Bremer Date: Fri, 8 Aug 2014 15:07:18 +0200 Subject: 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 Reviewed-by: Alex Blasche --- src/plugins/geoservices/osm/qgeoroutereplyosm.cpp | 13 +++++++++++-- 1 file 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(); -- cgit v1.2.3