From 7d4e170f449a42fa94f5a1348f302352328f089a Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Wed, 8 Apr 2015 14:58:08 +0100 Subject: [PATCH] location-source: No speed calculation if same timestamps If timestamps on new and existing location are the same, it doesn't make sense to calculate speed. Also if it wasn't for the guard in gclue_location_set_speed_from_prev_location() for such situation, it will end up with a "division by zero". https://bugs.freedesktop.org/show_bug.cgi?id=89852 --- src/gclue-location-source.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gclue-location-source.c b/src/gclue-location-source.c index 46ed053..9e67b9c 100644 --- a/src/gclue-location-source.c +++ b/src/gclue-location-source.c @@ -280,9 +280,17 @@ gclue_location_source_set_location (GClueLocationSource *source, speed = gclue_location_get_speed (location); if (speed == GCLUE_LOCATION_SPEED_UNKNOWN) { - if (cur_location != NULL) - gclue_location_set_speed_from_prev_location - (priv->location, cur_location); + if (cur_location != NULL) { + guint64 cur_timestamp, timestamp; + + timestamp = geocode_location_get_timestamp (gloc); + cur_timestamp = geocode_location_get_timestamp + (GEOCODE_LOCATION (cur_location)); + + if (timestamp != cur_timestamp) + gclue_location_set_speed_from_prev_location + (priv->location, cur_location); + } } else { gclue_location_set_speed (priv->location, speed); } -- 2.1.0