diff options
Diffstat (limited to 'src/plugins')
3 files changed, 32 insertions, 19 deletions
diff --git a/src/plugins/position/npe_backend/qgeopositioninfosource_npe_backend.cpp b/src/plugins/position/npe_backend/qgeopositioninfosource_npe_backend.cpp index 0807f8b2..1ad8905b 100644 --- a/src/plugins/position/npe_backend/qgeopositioninfosource_npe_backend.cpp +++ b/src/plugins/position/npe_backend/qgeopositioninfosource_npe_backend.cpp @@ -43,7 +43,8 @@ QGeoPositionInfoSourceNpeBackend::QGeoPositionInfoSourceNpeBackend(QObject *parent): - QGeoPositionInfoSource(parent), locationOngoing(false), timeoutSent(false), mPositionError(QGeoPositionInfoSource::UnknownSourceError), m_locationdConn(0) + QGeoPositionInfoSource(parent), m_locationdConn(0), trackingOngoing(false), timeoutSent(false), + mPositionError(QGeoPositionInfoSource::UnknownSourceError) { requestTimer = new QTimer(this); QObject::connect(requestTimer, SIGNAL(timeout()), this, SLOT(requestTimerExpired())); @@ -147,8 +148,8 @@ int QGeoPositionInfoSourceNpeBackend::minimumUpdateInterval() const void QGeoPositionInfoSourceNpeBackend::startUpdates() { - if (!locationOngoing) { - locationOngoing = true; + if (!trackingOngoing) { + trackingOngoing = true; m_locationdConn->startPositionUpdates(); } } @@ -156,9 +157,12 @@ void QGeoPositionInfoSourceNpeBackend::startUpdates() void QGeoPositionInfoSourceNpeBackend::stopUpdates() { - if ( locationOngoing && !requestTimer->isActive() ) { - locationOngoing = false; - m_locationdConn->stopPositionUpdates(); + if (trackingOngoing) { + trackingOngoing = false; + + // if there's still a pending position request, wait for it to complete before stopping position updates + if (!requestTimer->isActive()) + m_locationdConn->stopPositionUpdates(); } } @@ -177,12 +181,10 @@ void QGeoPositionInfoSourceNpeBackend::requestUpdate(int timeout) return; } // get position as fast as possible in case of ongoing satellite based session - if ( locationOngoing ) { + if ( trackingOngoing ) { if ( QGeoPositionInfoSource::updateInterval() != minimumInterval) m_locationdConn->setUpdateInterval(minimumInterval); - } - // request the update only if no tracking session is active - if ( !locationOngoing) { + } else { // request the update only if no tracking session is active m_locationdConn->requestPositionUpdate(); } requestTimer->start(timeout); @@ -202,10 +204,14 @@ void QGeoPositionInfoSourceNpeBackend::shutdownRequestSession() { requestTimer->stop(); // Restore updateInterval from before Request Session - if ( locationOngoing ) { + if (trackingOngoing) { int minimumInterval = minimumUpdateInterval(); if ( QGeoPositionInfoSource::updateInterval() != minimumInterval) setUpdateInterval(QGeoPositionInfoSource::updateInterval()); + } else { + // If our timer expired before we could get a fix, make sure we stop the location daemon position request + // (which would otherwise go on until a fix is obtained). + m_locationdConn->stopPositionUpdates(); } } diff --git a/src/plugins/position/npe_backend/qgeopositioninfosource_npe_backend_p.h b/src/plugins/position/npe_backend/qgeopositioninfosource_npe_backend_p.h index 36d16c7a..0f170c85 100644 --- a/src/plugins/position/npe_backend/qgeopositioninfosource_npe_backend_p.h +++ b/src/plugins/position/npe_backend/qgeopositioninfosource_npe_backend_p.h @@ -81,7 +81,7 @@ private: void setError(QGeoPositionInfoSource::Error positionError); void shutdownRequestSession(); LocationDaemonConnection* m_locationdConn; - bool locationOngoing; + bool trackingOngoing; bool timeoutSent; QTimer* requestTimer; QGeoPositionInfoSource::Error mPositionError; diff --git a/src/plugins/position/npe_backend/qgeosatelliteinfosource_npe_backend.cpp b/src/plugins/position/npe_backend/qgeosatelliteinfosource_npe_backend.cpp index 47b6514e..055fa229 100644 --- a/src/plugins/position/npe_backend/qgeosatelliteinfosource_npe_backend.cpp +++ b/src/plugins/position/npe_backend/qgeosatelliteinfosource_npe_backend.cpp @@ -50,8 +50,9 @@ #define SATELLITES_STATUS_USED_POS 0x0004 // -------------1-- -QGeoSatelliteInfoSourceNpeBackend::QGeoSatelliteInfoSourceNpeBackend(QObject *parent): QGeoSatelliteInfoSource(parent), - satOngoing(false), mSatelliteError(QGeoSatelliteInfoSource::UnknownSourceError), m_locationdConn(0) +QGeoSatelliteInfoSourceNpeBackend::QGeoSatelliteInfoSourceNpeBackend(QObject *parent): + QGeoSatelliteInfoSource(parent),m_locationdConn(0), satOngoing(false), + mSatelliteError(QGeoSatelliteInfoSource::UnknownSourceError) { requestTimer = new QTimer(this); QObject::connect(requestTimer, SIGNAL(timeout()), this, SLOT(requestTimerExpired())); @@ -98,9 +99,12 @@ void QGeoSatelliteInfoSourceNpeBackend::startUpdates() void QGeoSatelliteInfoSourceNpeBackend::stopUpdates() { - if (satOngoing && !requestTimer->isActive()) { + if (satOngoing) { satOngoing = false; - m_locationdConn->stopSatelliteUpdates(); + + // if there's still a pending sat update request, wait for it to complete before stopping satellite updates + if (!requestTimer->isActive()) + m_locationdConn->stopSatelliteUpdates(); } } @@ -121,10 +125,9 @@ void QGeoSatelliteInfoSourceNpeBackend::requestUpdate(int timeout) if ( satOngoing ) { if ( QGeoSatelliteInfoSource::updateInterval() != minimumInterval) m_locationdConn->setUpdateInterval(minimumInterval); - } - // request the update only if no tracking session is active - if ( !satOngoing) + } else { // request the update only if no tracking session is active m_locationdConn->requestSatelliteUpdate(); + } requestTimer->start(timeout); } } @@ -145,6 +148,10 @@ void QGeoSatelliteInfoSourceNpeBackend::shutdownRequestSession() int minimumInterval = minimumUpdateInterval(); if ( QGeoSatelliteInfoSource::updateInterval() != minimumInterval) setUpdateInterval(QGeoSatelliteInfoSource::updateInterval()); + } else { + // If our timer expired before we could get a sat update, make sure we stop the locationd request + // (which would otherwise go on until a valid satellite update is obtained). + m_locationdConn->stopSatelliteUpdates(); } } |