[nautilus] places-sidebar: cancel the hostnamed proxy creation on dispose



commit 480b1daf8814063f348d0f75082353a2f6a3eab3
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Jan 15 14:36:54 2013 -0500

    places-sidebar: cancel the hostnamed proxy creation on dispose
    
    It might happen that the sidebar is disposed before the async proxy
    creation completes, leading to accessing invalid memory. To avoid this,
    pass a GCancellable to the async operation, and cancel it during
    dispose.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=895684

 src/nautilus-places-sidebar.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c
index 224a2da..a7b5b15 100644
--- a/src/nautilus-places-sidebar.c
+++ b/src/nautilus-places-sidebar.c
@@ -99,6 +99,7 @@ typedef struct {
 	NautilusWindowOpenFlags go_to_after_mount_flags;
 
 	GDBusProxy *hostnamed_proxy;
+	GCancellable *hostnamed_cancellable;
 	char *hostname;
 
 	guint bookmarks_changed_id;
@@ -3061,6 +3062,8 @@ hostname_proxy_new_cb (GObject      *source_object,
 	GError *error = NULL;
 
 	sidebar->hostnamed_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+	g_clear_object (&sidebar->hostnamed_cancellable);
+
 	if (error != NULL) {
 		g_debug ("Failed to create D-Bus proxy: %s", error->message);
 		g_error_free (error);
@@ -3261,13 +3264,14 @@ nautilus_places_sidebar_init (NautilusPlacesSidebar *sidebar)
 				  sidebar);
 
 	sidebar->hostname = g_strdup (_("Computer"));
+	sidebar->hostnamed_cancellable = g_cancellable_new ();
 	g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
 				  G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES,
 				  NULL,
 				  "org.freedesktop.hostname1",
 				  "/org/freedesktop/hostname1",
 				  "org.freedesktop.hostname1",
-				  NULL,
+				  sidebar->hostnamed_cancellable,
 				  hostname_proxy_new_cb,
 				  sidebar);
 
@@ -3337,6 +3341,11 @@ nautilus_places_sidebar_dispose (GObject *object)
 		g_clear_object (&sidebar->volume_monitor);
 	}
 
+	if (sidebar->hostnamed_cancellable != NULL) {
+		g_cancellable_cancel (sidebar->hostnamed_cancellable);
+		g_clear_object (&sidebar->hostnamed_cancellable);
+	}
+
 	g_clear_object (&sidebar->hostnamed_proxy);
 	g_free (sidebar->hostname);
 	sidebar->hostname = NULL;



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