Accepting request 87418 from home:vuntz:branches:GNOME:Factory

Help fix crashes in bluetooth

OBS-URL: https://build.opensuse.org/request/show/87418
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/gnome-bluetooth?expand=0&rev=79
This commit is contained in:
Vincent Untz 2011-10-12 06:56:24 +00:00 committed by Git OBS Bridge
parent 6b6f14df63
commit a8db97d788
3 changed files with 149 additions and 0 deletions

View File

@ -0,0 +1,139 @@
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

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Oct 11 08:06:14 UTC 2011 - vuntz@opensuse.org
- Add gnome-bluetooth-fix-crash.patch: fix various crashes in
libgnome-bluetooth, that help a bit getting bluetooth working in
GNOME. Part of bnc#722722.
-------------------------------------------------------------------
Mon Sep 26 10:35:12 UTC 2011 - vuntz@opensuse.org

View File

@ -28,6 +28,8 @@ Source: http://download.gnome.org/sources/gnome-bluetooth/3.2/%{name}-%{
Source1: 61-gnome-bluetooth-rfkill.rules
# PATCH-MISSING-TAG -- See http://en.opensuse.org/Packaging/Patches
Patch0: lxde-support.patch
# PATCH-FIX-UPSTREAM gnome-bluetooth-fix-crash.patch bgo#654172 bnc#722722 vuntz@opensuse.org -- Fix various crashes in libgnome-bluetooth due to leaking objects
Patch1: gnome-bluetooth-fix-crash.patch
BuildRequires: fdupes
BuildRequires: gnome-doc-utils-devel
BuildRequires: gobject-introspection-devel
@ -112,6 +114,7 @@ send files over bluetooth.
%setup -q
translation-update-upstream
%patch0 -p1
%patch1 -p1
%if 0%{?BUILD_FROM_VCS}
[ -x ./autogen.sh ] && NOCONFIGURE=1 ./autogen.sh