Commit 0c9e7372 authored by Wolfgang Bremer's avatar Wolfgang Bremer Committed by Alex Blasche
Browse files

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: default avatarAaron McCarthy <mccarthy.aaron@gmail.com>
Reviewed-by: default avatarAlex Blasche <alexander.blasche@digia.com>
Showing with 11 additions and 2 deletions
......@@ -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();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment