[libgweather] location-entry: fix cancellable and error handling



commit ed7a9acd973c792dbbde352d51241533a7212e37
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue Jul 1 14:56:36 2014 +0200

    location-entry: fix cancellable and error handling

 libgweather/location-entry.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/libgweather/location-entry.c b/libgweather/location-entry.c
index a9bb05a..2076f70 100644
--- a/libgweather/location-entry.c
+++ b/libgweather/location-entry.c
@@ -794,27 +794,33 @@ _got_places (GObject      *source_object,
     GWeatherLocationEntry *self = user_data;
     GError *error = NULL;
     GtkTreeStore *store = NULL;
-    GtkEntryCompletion *completion = gtk_entry_get_completion (user_data);
+    GtkEntryCompletion *completion;
 
     places = geocode_forward_search_finish (GEOCODE_FORWARD (source_object), result, &error);
     if (places == NULL) {
         /* return without touching anything if cancelled (the entry might have been disposed) */
         if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+            g_clear_error (&error);
             return;
         }
 
-        gtk_entry_completion_delete_action (completion, 0);
+        g_clear_error (&error);
+        completion = gtk_entry_get_completion (user_data);
         gtk_entry_completion_set_match_func (completion, matcher, NULL, NULL);
         gtk_entry_completion_set_model (completion, self->priv->model);
-        return;
+        goto out;
     }
 
+    completion = gtk_entry_get_completion (user_data);
     store = gtk_tree_store_new (4, G_TYPE_STRING, GEOCODE_TYPE_PLACE, G_TYPE_STRING, G_TYPE_STRING);
     g_list_foreach (places, fill_store, store);
     gtk_entry_completion_set_match_func (completion, new_matcher, NULL, NULL);
     gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (store));
-    gtk_entry_completion_delete_action (completion, 0);
     g_object_unref (store);
+
+ out:
+    gtk_entry_completion_delete_action (completion, 0);
+    g_clear_object (&self->priv->cancellable);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]