summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-08-12 16:44:49 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-08-12 16:44:49 +0200
commit226f454f8e2a7ba04e11c42e94181e6b33b73bf6 (patch)
tree0ec8732b3224108e7c5e194d05338a1b2623c42b
parentd36729c1632871782f31506d61d2f3d915533550 (diff)
parent6fd2a05e0cb87f7470f9df0cdcbfd9883a764ff6 (diff)
downloadqtlocation-226f454f8e2a7ba04e11c42e94181e6b33b73bf6.tar.gz
Merge "Merge remote-tracking branch 'origin/5.3' into 5.4" into refs/staging/5.4
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp27
-rw-r--r--src/plugins/geoservices/osm/qgeoroutereplyosm.cpp16
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)