From b97401c6e05a979396ef84f266a3a504cc768067 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 742b455..49d8c10 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