summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-11-21 12:30:47 (GMT)
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-11-28 21:44:16 (GMT)
commitcd24931b171f73d6ba71450493e9d5a8142a67a5 (patch)
tree8db71d16865a4a916b12aae23cc7a818abb2e437
parent3f06c2dad7c90771df3ea98435097bda9c08cbeb (diff)
downloadqtlocation-cd24931b171f73d6ba71450493e9d5a8142a67a5.tar.gz
Enforce numberAlternativeRoutes where possible when doing route requests
Change-Id: I321e802d795df36d8cdd1b8578e77094c500cc2e Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp2
-rw-r--r--src/plugins/geoservices/osm/qgeoroutereplyosm.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp b/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp
index 8fc3386..3099657 100644
--- a/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp
@@ -188,7 +188,7 @@ void QGeoRouteReplyMapbox::networkReplyFinished()
QList<QGeoRoute> list;
QJsonArray routes = object.value(QStringLiteral("routes")).toArray();
- for (int i = 0; i < routes.count(); i++) {
+ for (int i = 0; i < qMin(routes.count(), request().numberAlternativeRoutes() + 1); i++) {
QGeoRoute route = constructRoute(routes.at(i).toObject());
list.append(route);
}
diff --git a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp
index 6924fda..732e8d7 100644
--- a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp
+++ b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp
@@ -77,7 +77,7 @@ void QGeoRouteReplyOsm::networkReplyFinished()
QGeoRouteReply::Error error = parser->parseReply(routes, errorString, reply->readAll());
if (error == QGeoRouteReply::NoError) {
- setRoutes(routes.mid(0,1)); // TODO QTBUG-56426
+ setRoutes(routes.mid(0, request().numberAlternativeRoutes() + 1));
// setError(QGeoRouteReply::NoError, status); // can't do this, or NoError is emitted and does damages
setFinished(true);
} else {