diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-08-12 16:18:53 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-08-14 09:49:38 +0200 |
commit | a36d9e67e3b8168cb4d1eb76eda96ebb8242fd20 (patch) | |
tree | 1b97b986e154c150320f0109d218a57077172938 /examples/positioning/weatherinfo/appmodel.cpp | |
parent | 11fdb66dc5fe4822dacaca0b1afd0346446b5143 (diff) |
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/positioning/weatherinfo/appmodel.cpp')
-rw-r--r-- | examples/positioning/weatherinfo/appmodel.cpp | 17 |
1 files changed, 17 insertions, 0 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); |