aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-13 11:35:51 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-13 13:52:00 -0800
commit702d09df9fe582d253607589c4b88ccd62502883 (patch)
tree7d298d04327e59c0b169a10a8f4269654720da8a /core
parent4454cf0381625d91a74310e8abe3eb1de8ea83a1 (diff)
downloadsubsurface-702d09df9fe582d253607589c4b88ccd62502883.tar.gz
mobile/GPS: fix two errors in the GPS handling
First, the time zone adjustment was wrong - this as written could only ever have worked in UTC or by pure chance. Second, the order of alerting the UI of the availability of a GPS fix was also incorrect creating a race between the UI and our data structures. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r--core/gpslocation.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/core/gpslocation.cpp b/core/gpslocation.cpp
index 1da12fe5b..012b24403 100644
--- a/core/gpslocation.cpp
+++ b/core/gpslocation.cpp
@@ -126,7 +126,7 @@ QString GpsLocation::currentPosition()
if (!hasLocationsSource())
return tr("Unknown GPS location (no GPS source)");
if (m_trackers.count()) {
- QDateTime lastFixTime = timestampToDateTime(m_trackers.lastKey() + gettimezoneoffset());
+ QDateTime lastFixTime = timestampToDateTime(m_trackers.lastKey() - gettimezoneoffset());
QDateTime now = QDateTime::currentDateTime();
int delta = lastFixTime.secsTo(now);
qDebug() << "lastFixTime" << lastFixTime.toString() << "now" << now.toString() << "delta" << delta;
@@ -168,14 +168,13 @@ void GpsLocation::newPosition(QGeoPositionInfo pos)
lastCoord.distanceTo(pos.coordinate()) > prefs.distance_threshold) {
QString msg = QStringLiteral("received new position %1 after delta %2 threshold %3 (now %4 last %5)");
status(qPrintable(msg.arg(pos.coordinate().toString()).arg(delta).arg(prefs.time_threshold).arg(pos.timestamp().toString()).arg(timestampToDateTime(lastTime).toString())));
- waitingForPosition = false;
- acquiredPosition();
gpsTracker gt;
gt.when = thisTime;
gt.location = create_location(pos.coordinate().latitude(), pos.coordinate().longitude());
addFixToStorage(gt);
gpsTracker gtNew = m_trackers.last();
- qDebug() << "newest fix is now at" << timestampToDateTime(gtNew.when - gettimezoneoffset()).toString();
+ waitingForPosition = false;
+ acquiredPosition();
}
}