diff options
author | Jean Gressmann <jean.gressmann@nokia.com> | 2012-03-26 11:43:31 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-26 17:00:52 +0200 |
commit | 07846bc812be2a454ad7b70f7677407e80305372 (patch) | |
tree | 2cefc83625281027b88c8826c6f5f11968056583 /src | |
parent | 81b6dd047ae6939f2d743cc7b6d0ef8794b6aab7 (diff) | |
download | qtlocation-07846bc812be2a454ad7b70f7677407e80305372.tar.gz |
QtLocation: Nokia plugin now returns an error on invalid travel modes
The plugin now returns an error if more than one travel mode flag
is set at the same time.
Change-Id: Iee8254c53c599b0e79ff701dc4e000ba4659a400
Reviewed-by: Alex Wilson <alex.wilson@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp | 5 | ||||
-rw-r--r-- | src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp | 10 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp b/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp index 223fa733..f331c229 100644 --- a/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp +++ b/src/plugins/geoservices/nokia/qgeoroutexmlparser.cpp @@ -333,8 +333,11 @@ bool QGeoRouteXmlParser::parseMode(QGeoRoute *route) route->setTravelMode(QGeoRouteRequest::BicycleTravel); else if (value == "truck") route->setTravelMode(QGeoRouteRequest::TruckTravel); - else // unsupported optimization + else { + // unsupported mode + m_reader->raiseError(QString("Unsupported travel mode '\"%1\"'").arg(value)); return false; + } } else { m_reader->skipCurrentElement(); } diff --git a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp index b509c748..bc6e8234 100644 --- a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp @@ -223,6 +223,16 @@ bool QGeoRoutingManagerEngineNokia::checkEngineSupport(const QGeoRouteRequest &r if ((travelModes & supportedTravelModes()) != travelModes) return false; + // Count the number of set bits (= number of travel modes) (popcount) + int count = 0; + + for (unsigned bits = travelModes; bits; bits >>= 1) + count += (bits & 1); + + // We only allow one travel mode at a time + if (count != 1) + return false; + return true; } |