File gnome-bluetooth-fix-crash.patch of Package gnome-bluetooth

From 00e1b334b3014ce9ed72b5d3391313467d6fe181 Mon Sep 17 00:00:00 2001
From: Vincent Untz <vuntz@gnome.org>
Date: Fri, 7 Oct 2011 15:46:51 +0200
Subject: [PATCH 1/2] 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)
-- 
1.7.7


From 63b442bb8a81776887350bad516943ddd61852b8 Mon Sep 17 00:00:00 2001
From: Vincent Untz <vuntz@gnome.org>
Date: Tue, 11 Oct 2011 09:46:52 +0200
Subject: [PATCH 2/2] lib: Do not leak proxies for detectable interfaces of
 devices

This avoids signals that will cause crashes.

https://bugzilla.gnome.org/show_bug.cgi?id=654172
---
 lib/bluetooth-client.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index d7af201..e2f66c7 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -103,6 +103,7 @@ struct _BluetoothClientPrivate {
 	DBusGProxy *manager;
 	GtkTreeStore *store;
 	GtkTreeRowReference *default_adapter;
+	GSList *horrible_workaround_for_leaked_ifaces;
 };
 
 enum {
@@ -266,6 +267,7 @@ device_services_changed (DBusGProxy *iface, const char *property,
 static GHashTable *
 device_list_nodes (DBusGProxy *device, BluetoothClient *client, gboolean connect_signal)
 {
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
 	GHashTable *table;
 	guint i;
 
@@ -333,6 +335,8 @@ device_list_nodes (DBusGProxy *device, BluetoothClient *client, gboolean connect
 				dbus_g_proxy_connect_signal(iface, "PropertyChanged",
 							    G_CALLBACK(device_services_changed), client, NULL);
 			}
+
+			priv->horrible_workaround_for_leaked_ifaces = g_slist_append (priv->horrible_workaround_for_leaked_ifaces, iface);
 		}
 	}
 
@@ -1055,6 +1059,7 @@ disconnect_from_proxy_helper (GtkTreeModel *model,
 static void bluetooth_client_finalize(GObject *client)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	GSList *l;
 
 	DBG("client %p", client);
 
@@ -1079,6 +1084,15 @@ static void bluetooth_client_finalize(GObject *client)
 	if (priv->default_adapter)
 		gtk_tree_row_reference_free (priv->default_adapter);
 
+	for (l = priv->horrible_workaround_for_leaked_ifaces; l != NULL; l = l->next) {
+		DBusGProxy *iface = l->data;
+
+		g_signal_handlers_disconnect_by_func(iface,
+					device_services_changed, client);
+		g_object_unref (iface);
+	}
+	g_slist_free (priv->horrible_workaround_for_leaked_ifaces);
+
 	G_OBJECT_CLASS(bluetooth_client_parent_class)->finalize(client);
 }
 
-- 
1.7.7

openSUSE Build Service is sponsored by