summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-08-12 16:18:53 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-08-14 09:49:38 +0200
commita36d9e67e3b8168cb4d1eb76eda96ebb8242fd20 (patch)
tree1b97b986e154c150320f0109d218a57077172938 /examples
parent11fdb66dc5fe4822dacaca0b1afd0346446b5143 (diff)
downloadqtlocation-a36d9e67e3b8168cb4d1eb76eda96ebb8242fd20.tar.gz
Don't hang weatherinfo if position source has an error.
We continue with the simulation mode. Task-number: QTBUG-40702 Change-Id: I130b0080a198a218803986fb7ff06fdd0b83186a Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/positioning/weatherinfo/appmodel.cpp17
-rw-r--r--examples/positioning/weatherinfo/appmodel.h3
2 files changed, 19 insertions, 1 deletions
diff --git a/examples/positioning/weatherinfo/appmodel.cpp b/examples/positioning/weatherinfo/appmodel.cpp
index d0a37265..30d990d4 100644
--- a/examples/positioning/weatherinfo/appmodel.cpp
+++ b/examples/positioning/weatherinfo/appmodel.cpp
@@ -233,6 +233,8 @@ void AppModel::networkSessionOpened()
d->useGps = true;
connect(d->src, SIGNAL(positionUpdated(QGeoPositionInfo)),
this, SLOT(positionUpdated(QGeoPositionInfo)));
+ connect(d->src, SIGNAL(error(QGeoPositionInfoSource::Error)),
+ this, SLOT(positionError(QGeoPositionInfoSource::Error)));
d->src->startUpdates();
} else {
d->useGps = false;
@@ -277,6 +279,21 @@ void AppModel::positionUpdated(QGeoPositionInfo gpsPos)
d->geoReplyMapper, SLOT(map()));
}
+void AppModel::positionError(QGeoPositionInfoSource::Error e)
+{
+ qWarning() << "Position source error. Falling back to simulation mode.";
+ // cleanup insufficient QGeoPositionInfoSource instance
+ d->src->stopUpdates();
+ d->src->deleteLater();
+ d->src = 0;
+
+ // activate simulation mode
+ d->useGps = false;
+ d->city = "Brisbane";
+ emit cityChanged();
+ this->refreshWeather();
+}
+
void AppModel::handleGeoNetworkData(QObject *replyObj)
{
QNetworkReply *networkReply = qobject_cast<QNetworkReply*>(replyObj);
diff --git a/examples/positioning/weatherinfo/appmodel.h b/examples/positioning/weatherinfo/appmodel.h
index e0d32148..16297236 100644
--- a/examples/positioning/weatherinfo/appmodel.h
+++ b/examples/positioning/weatherinfo/appmodel.h
@@ -46,7 +46,7 @@
#include <QtNetwork/QNetworkReply>
#include <QtQml/QQmlListProperty>
-#include <qgeopositioninfo.h>
+#include <QtPositioning/QGeoPositionInfoSource>
//! [0]
class WeatherData : public QObject {
@@ -146,6 +146,7 @@ public slots:
private slots:
void networkSessionOpened();
void positionUpdated(QGeoPositionInfo gpsPos);
+ void positionError(QGeoPositionInfoSource::Error e);
// these would have QNetworkReply* params but for the signalmapper
void handleGeoNetworkData(QObject *networkReply);
void handleWeatherNetworkData(QObject *networkReply);