diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-08-12 12:50:23 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-08-12 12:50:23 +0200 |
commit | 6fd2a05e0cb87f7470f9df0cdcbfd9883a764ff6 (patch) | |
tree | d291ede9b7d52e93ae75cabae0cb49522877500c | |
parent | 5dddfc5121cac154023569fe69b417054ba53188 (diff) | |
parent | 09f68b95b125cef0c8e93092b0aad3a3e794913f (diff) | |
download | qtlocation-6fd2a05e0cb87f7470f9df0cdcbfd9883a764ff6.tar.gz |
Merge remote-tracking branch 'origin/5.3' into 5.4
Change-Id: I48f866a8fbb8af18dee640eada24556d097059b0
-rw-r--r-- | src/imports/location/qdeclarativegeomap.cpp | 27 | ||||
-rw-r--r-- | src/plugins/geoservices/osm/qgeoroutereplyosm.cpp | 16 |
2 files changed, 20 insertions, 23 deletions
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp index 5d40935f..32d378fa 100644 --- a/src/imports/location/qdeclarativegeomap.cpp +++ b/src/imports/location/qdeclarativegeomap.cpp @@ -1075,13 +1075,13 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine) double bottomRightY = 0; // find bounds of all map items - QGeoCoordinate geoCenter; - QDoubleVector2D centerPt; int itemCount = 0; for (int i = 0; i < mapItems_.count(); ++i) { if (!mapItems_.at(i)) continue; QDeclarativeGeoMapItemBase *item = mapItems_.at(i).data(); + if (!item) + continue; // skip quick items in the first pass and refine the fit later if (refine) { @@ -1091,26 +1091,11 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine) continue; } - // account for the special case - circle - QDeclarativeCircleMapItem *circleItem = - qobject_cast<QDeclarativeCircleMapItem *>(item); + topLeftX = item->position().x(); + topLeftY = item->position().y(); + bottomRightX = topLeftX + item->width(); + bottomRightY = topLeftY + item->height(); - if ((!circleItem || !circleItem->center().isValid()) && !item) - continue; - if (circleItem) { - geoCenter = circleItem->center(); - centerPt = map_->coordinateToScreenPosition(geoCenter, false); - topLeftX = centerPt.x() - circleItem->width() / 2.0; - topLeftY = centerPt.y() - circleItem->height() / 2.0; - bottomRightX = centerPt.x() + circleItem->width() / 2.0; - bottomRightY = centerPt.y() + circleItem->height() / 2.0; - } else if (item) { - topLeftX = item->position().x(); - topLeftY = item->position().y(); - bottomRightX = topLeftX + item->width(); - bottomRightY = topLeftY + item->height(); - ++itemCount; - } if (itemCount == 0) { minX = topLeftX; maxX = bottomRightX; diff --git a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp index 79298543..740828f3 100644 --- a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp +++ b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp @@ -339,6 +339,7 @@ void QGeoRouteReplyOsm::networkReplyFinished() if (m_reply->error() != QNetworkReply::NoError) { setError(QGeoRouteReply::CommunicationError, m_reply->errorString()); m_reply->deleteLater(); + m_reply = 0; return; } @@ -348,8 +349,18 @@ 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(); + m_reply = 0; + return; + } QJsonObject routeSummary = object.value(QStringLiteral("route_summary")).toObject(); @@ -388,6 +399,7 @@ void QGeoRouteReplyOsm::networkReplyFinished() } m_reply->deleteLater(); + m_reply = 0; } void QGeoRouteReplyOsm::networkReplyError(QNetworkReply::NetworkError error) |