summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@jollamobile.com>2014-02-13 14:19:57 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-04 02:39:01 +0100
commit47b13b35cff080696108f10064d38c68cbebc9c2 (patch)
treececcdc8a674674f58e6c2f5f1ab61e7ab9ae3eb5
parent8731c5e383d54881ecf6e15fdd55b412ef4bfcf9 (diff)
Emit updateTimeout() when regular position updates aren't received.
The documentation indicates that the updateTimeout() signal should be emitted once when the source determines that regular updates will no longer be received. [ChangeLog][QtPositioning][Geoclue] The Geoclue position source now emits the updateTimeout() signal when position updates do not arrive in a timely manner. Change-Id: I87c31a60a8e718a0ab72a1e270a93e967307f77a Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r--src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp20
-rw-r--r--src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h1
2 files changed, 13 insertions, 8 deletions
diff --git a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp
index 259dde6d..9c3c0045 100644
--- a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp
+++ b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp
@@ -125,9 +125,9 @@ static double knotsToMetersPerSecond(double knots)
QGeoPositionInfoSourceGeoclueMaster::QGeoPositionInfoSourceGeoclueMaster(QObject *parent)
: QGeoPositionInfoSource(parent), QGeoclueMaster(this), m_updateInterval(0), m_pos(0), m_vel(0),
- m_lastPositionIsFresh(false), m_lastVelocityIsFresh(false), m_lastVelocity(qQNaN()),
- m_lastDirection(qQNaN()), m_lastClimb(qQNaN()), m_lastPositionFromSatellite(false),
- m_methods(AllPositioningMethods), m_running(false)
+ m_lastPositionIsFresh(false), m_lastVelocityIsFresh(false), m_regularUpdateTimedOut(false),
+ m_lastVelocity(qQNaN()), m_lastDirection(qQNaN()), m_lastClimb(qQNaN()),
+ m_lastPositionFromSatellite(false), m_methods(AllPositioningMethods), m_running(false)
{
#ifndef QT_NO_DATASTREAM
// Load the last known location
@@ -241,14 +241,13 @@ void QGeoPositionInfoSourceGeoclueMaster::regularUpdateFailed()
#ifdef Q_LOCATION_GEOCLUE_DEBUG
qDebug() << "QGeoPositionInfoSourceGeoclueMaster regular update failed.";
#endif
- // Emit timeout and keep on listening in case error condition clears.
- // Currently this is emitted each time an error occurs, and thereby it assumes
- // that there does not come many erroneous updates from position source.
- // This assumption may be invalid.
+
m_lastVelocityIsFresh = false;
m_lastPositionIsFresh = false;
- if (m_updateTimer.isActive())
+ if (m_updateTimer.isActive() && !m_regularUpdateTimedOut) {
+ m_regularUpdateTimedOut = true;
emit updateTimeout();
+ }
}
void QGeoPositionInfoSourceGeoclueMaster::regularUpdateSucceeded(GeocluePositionFields fields,
@@ -260,6 +259,7 @@ void QGeoPositionInfoSourceGeoclueMaster::regularUpdateSucceeded(GeocluePosition
{
m_lastPosition = geoclueToPositionInfo(fields, timestamp, latitude, longitude, altitude, accuracy);
m_lastPositionIsFresh = true;
+ m_regularUpdateTimedOut = false;
if (m_lastVelocityIsFresh) {
if (!qIsNaN(m_lastVelocity))
m_lastPosition.setAttribute(QGeoPositionInfo::GroundSpeed, m_lastVelocity);
@@ -317,6 +317,7 @@ void QGeoPositionInfoSourceGeoclueMaster::setPreferredPositioningMethods(Positio
m_lastPositionIsFresh = false;
m_lastVelocityIsFresh = false;
+ m_regularUpdateTimedOut = false;
// Don't start Geoclue provider until necessary. Don't currently have a master client, no need
// no recreate one.
@@ -465,6 +466,9 @@ void QGeoPositionInfoSourceGeoclueMaster::startUpdatesTimeout()
emit positionUpdated(m_lastPosition);
m_lastPositionIsFresh = false;
m_lastVelocityIsFresh = false;
+ } else if (!m_regularUpdateTimedOut) {
+ m_regularUpdateTimedOut = true;
+ emit updateTimeout();
}
}
diff --git a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h
index 7e980317..ba385782 100644
--- a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h
+++ b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h
@@ -125,6 +125,7 @@ private:
QTimer m_requestTimer;
bool m_lastPositionIsFresh;
bool m_lastVelocityIsFresh;
+ bool m_regularUpdateTimedOut;
double m_lastVelocity;
double m_lastDirection;
double m_lastClimb;