[gnome-bluetooth/gnome-3-2] lib: Disconnect signals from adapters and devices on finalize



commit 8be8b92664230809c8bd263f58955109bc639e20
Author: Vincent Untz <vuntz gnome org>
Date:   Fri Oct 7 15:46:51 2011 +0200

    lib: Disconnect signals from adapters and devices on finalize
    
    This avoids some crashes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=661118
    
    https://bugzilla.gnome.org/show_bug.cgi?id=654172

 lib/bluetooth-client.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 86680c3..d7af201 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -1021,6 +1021,37 @@ bluetooth_client_set_property (GObject        *object,
 	}
 }
 
+static gboolean
+disconnect_from_proxy_helper (GtkTreeModel *model,
+			      GtkTreePath  *path,
+			      GtkTreeIter  *iter,
+			      gpointer      data)
+{
+	BluetoothClient *client = data;
+	DBusGProxy *proxy;
+
+	gtk_tree_model_get(model, iter,
+			   BLUETOOTH_COLUMN_PROXY, &proxy, -1);
+
+	/* adapters */
+	g_signal_handlers_disconnect_by_func(proxy,
+				adapter_changed, client);
+	g_signal_handlers_disconnect_by_func(proxy,
+				device_created, client);
+	g_signal_handlers_disconnect_by_func(proxy,
+				device_removed, client);
+	g_signal_handlers_disconnect_by_func(proxy,
+				device_found, client);
+
+	/* devices */
+	g_signal_handlers_disconnect_by_func(proxy,
+				device_changed, client);
+
+	g_object_unref(proxy);
+
+	return FALSE;
+}
+
 static void bluetooth_client_finalize(GObject *client)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
@@ -1041,6 +1072,8 @@ static void bluetooth_client_finalize(GObject *client)
 					default_adapter_changed, client);
 	g_object_unref(priv->manager);
 
+	gtk_tree_model_foreach (GTK_TREE_MODEL(priv->store), disconnect_from_proxy_helper, client);
+
 	g_object_unref(priv->store);
 
 	if (priv->default_adapter)



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