summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-11-08 17:30:12 +0100
committerIvan Solovev <ivan.solovev@qt.io>2021-11-10 14:02:24 +0100
commitec43d4172bf2d8243c546a737c3f930009559459 (patch)
treeb15ecc6380a54a01141959a29618f0f4ca7cb5af
parent95b437b54cac265b5eb78689a46ddc676024a720 (diff)
downloadqtlocation-ec43d4172bf2d8243c546a737c3f930009559459.tar.gz
Fix position handling in geoclue2 plugin
The pre-existing code was incorrect due to the operation priority. The result of the comparison was assigned to the variables, so they were always initialized with 0 or 1 instead of real values. Also use std::numeric_limits<double>::lowest(), because the altitude can have a negative value (when we are below sea level). This commit is a manual cherry-pick from qtpositioning.git dev branch Fixes: QTBUG-97722 Change-Id: I2d5beddfdf6d7b4fc626d6b09f4923c968016428 (cherry picked from commit 70b7818e1fc585f8bac43b721f3dd172b7489d07) Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
-rw-r--r--src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp b/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp
index 8e54a1ea..7f3eb5db 100644
--- a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp
+++ b/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp
@@ -410,7 +410,8 @@ void QGeoPositionInfoSourceGeoclue2::handleNewLocation(const QDBusObjectPath &ol
} else {
QGeoCoordinate coordinate(location.latitude(),
location.longitude());
- if (const auto altitude = location.altitude() > std::numeric_limits<double>::min())
+ const auto altitude = location.altitude();
+ if (altitude > std::numeric_limits<double>::lowest())
coordinate.setAltitude(altitude);
const Timestamp ts = location.timestamp();
@@ -428,9 +429,11 @@ void QGeoPositionInfoSourceGeoclue2::handleNewLocation(const QDBusObjectPath &ol
m_lastPositionFromSatellite = qFuzzyCompare(accuracy, 0.0);
m_lastPosition.setAttribute(QGeoPositionInfo::HorizontalAccuracy, accuracy);
- if (const auto speed = location.speed() >= 0.0)
+ const auto speed = location.speed();
+ if (speed >= 0.0)
m_lastPosition.setAttribute(QGeoPositionInfo::GroundSpeed, speed);
- if (const auto heading = location.heading() >= 0.0)
+ const auto heading = location.heading();
+ if (heading >= 0.0)
m_lastPosition.setAttribute(QGeoPositionInfo::Direction, heading);
emit positionUpdated(m_lastPosition);