[gtk+] GtkPlacesSidebar: Cancel async ops when finalized



commit 768c0c21b5b28a8a5776054eb03638e8a157dc2a
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Sep 3 23:29:51 2014 -0400

    GtkPlacesSidebar: Cancel async ops when finalized
    
    This is the common practice for objects that start async operations.
    https://bugzilla.gnome.org/show_bug.cgi?id=735953

 gtk/gtkplacessidebar.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 7665ebd..70bccaf 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -144,6 +144,7 @@ struct _GtkPlacesSidebar {
 
   /* volume mounting - delayed open process */
   GtkPlacesOpenFlags go_to_after_mount_open_flags;
+  GCancellable *cancellable;
 
   GtkWidget *popup_menu;
   GSList *shortcuts;
@@ -806,7 +807,7 @@ add_application_shortcuts (GtkPlacesSidebar *sidebar)
                                "standard::display-name,standard::symbolic-icon",
                                G_FILE_QUERY_INFO_NONE,
                                G_PRIORITY_DEFAULT,
-                               NULL,
+                               sidebar->cancellable,
                                on_app_shortcuts_query_complete,
                                sidebar);
     }
@@ -1234,7 +1235,7 @@ update_places (GtkPlacesSidebar *sidebar)
                                "standard::display-name,standard::symbolic-icon",
                                G_FILE_QUERY_INFO_NONE,
                                G_PRIORITY_DEFAULT,
-                               NULL,
+                               sidebar->cancellable,
                                on_bookmark_query_info_complete,
                                clos);
     }
@@ -3771,6 +3772,8 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
 
   gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (sidebar)), GTK_STYLE_CLASS_SIDEBAR);
 
+  sidebar->cancellable = g_cancellable_new ();
+
   create_volume_monitor (sidebar);
 
   sidebar->open_flags = GTK_PLACES_OPEN_NORMAL;
@@ -4053,6 +4056,13 @@ gtk_places_sidebar_dispose (GObject *object)
 
   sidebar = GTK_PLACES_SIDEBAR (object);
 
+  if (sidebar->cancellable)
+    {
+      g_cancellable_cancel (sidebar->cancellable);
+      g_object_unref (sidebar->cancellable);
+      sidebar->cancellable = NULL;
+    }
+
   sidebar->tree_view = NULL;
 
   if (sidebar->drag_leave_timeout_id)


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