[gtk+] placesview: keep reference during network fetching



commit d4bf2156119c7be55d1a7cc6cada9f800a33b024
Author: Christian Kellner <christian kellner me>
Date:   Mon Sep 5 13:41:16 2016 +0200

    placesview: keep reference during network fetching
    
    Analogous to (un)mount operation, we now keep a reference around
    during the ongoing operation and make use of the destroyed flag
    to check if we are still alive or if we have been cancelled as
    a result of the widget being destroyed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764979

 gtk/gtkplacesview.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index 5bf15b6..0105800 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -970,8 +970,11 @@ network_enumeration_next_files_finished (GObject      *source_object,
       g_list_free_full (detected_networks, g_object_unref);
     }
 
-  /* avoid to update widgets if the operation was cancelled in finalize */
-  if (priv->listbox != NULL)
+  g_object_unref (view);
+
+  /* avoid to update widgets if we are already destroyed
+     (and got cancelled s a result of that) */
+  if (!priv->destroyed)
     {
       update_network_state (view);
       update_loading (view);
@@ -997,6 +1000,7 @@ network_enumeration_finished (GObject      *source_object,
         g_warning ("Failed to fetch network locations: %s", error->message);
 
       g_clear_error (&error);
+      g_object_unref (GTK_PLACES_VIEW (user_data));
     }
   else
     {
@@ -1036,6 +1040,7 @@ fetch_networks (GtkPlacesView *view)
   gtk_places_view_set_fetching_networks (view, TRUE);
   update_network_state (view);
 
+  g_object_ref (view);
   g_file_enumerate_children_async (network_file,
                                    
"standard::type,standard::target-uri,standard::name,standard::display-name,standard::icon",
                                    G_FILE_QUERY_INFO_NONE,


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