From 093c7b7b64293adb9e8e31d08e557320a47dc757 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 8 Apr 2010 13:51:41 +0200 Subject: geocode_cb: don't update location if we didn't get the full position --- libempathy/empathy-contact.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index 4f554419c..387370097 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -1239,26 +1239,23 @@ geocode_cb (GeoclueGeocode *geocode, if (error != NULL) { DEBUG ("Error geocoding location : %s", error->message); - g_object_unref (geocode); - g_object_unref (contact); - return; + goto out; } - if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE) - { - new_value = tp_g_value_slice_new_double (latitude); - g_hash_table_replace (location, g_strdup (EMPATHY_LOCATION_LAT), - new_value); - DEBUG ("\t - Latitude: %f", latitude); - } + /* No need to change location if we didn't find the position */ + if (!(fields & GEOCLUE_POSITION_FIELDS_LATITUDE)) + goto out; - if (fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) - { - new_value = tp_g_value_slice_new_double (longitude); - g_hash_table_replace (location, g_strdup (EMPATHY_LOCATION_LON), - new_value); - DEBUG ("\t - Longitude: %f", longitude); - } + if (!(fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)) + goto out; + + g_hash_table_insert (location, g_strdup (EMPATHY_LOCATION_LAT), + tp_g_value_slice_new_double (latitude)); + DEBUG ("\t - Latitude: %f", latitude); + + g_hash_table_insert (location, g_strdup (EMPATHY_LOCATION_LON), + tp_g_value_slice_new_double (longitude)); + DEBUG ("\t - Longitude: %f", longitude); if (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE) { @@ -1270,6 +1267,7 @@ geocode_cb (GeoclueGeocode *geocode, /* Don't change the accuracy as we used an address to get this position */ g_object_notify (contact, "location"); +out: g_object_unref (geocode); g_object_unref (contact); } -- cgit v1.2.3