fix position handling in geoclue2 plugin
authorDebian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
Mon, 13 Jun 2022 18:36:32 +0000 (19:36 +0100)
committerDmitry Shachnev <mitya57@debian.org>
Mon, 13 Jun 2022 18:36:32 +0000 (19:36 +0100)
Origin: upstream, https://code.qt.io/cgit/qt/qtpositioning.git/commit/?id=70b7818e1fc585f8
Last-Update: 2021-11-10

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).

Gbp-Pq: Name geoclue2_fix_position_handling.diff

src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp

index 10484e3bbe11f5da3ecd7a4f31febcdb714c7cd7..f157a03aec3ae03f780ccf4aefd36ab94a716900 100644 (file)
@@ -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);