Blame SOURCES/0001-bluetooth-Fix-crash-when-exiting-during-a-connection.patch

5041aa
From 5d3457e46dcca007296f5dd7f78f59272c0072d3 Mon Sep 17 00:00:00 2001
5041aa
From: Bastien Nocera <hadess@hadess.net>
5041aa
Date: Fri, 20 Sep 2013 19:04:07 +0200
5041aa
Subject: [PATCH] bluetooth: Fix crash when exiting during a connection
5041aa
5041aa
If a connection is on-going, make sure to cancel it before
5041aa
when finalizing the panel, or we will be crashing once
5041aa
we've finished connecting/disconnecting.
5041aa
5041aa
https://bugzilla.gnome.org/show_bug.cgi?id=708478
5041aa
---
5041aa
 panels/bluetooth/cc-bluetooth-panel.c | 18 ++++++++++++++----
5041aa
 1 file changed, 14 insertions(+), 4 deletions(-)
5041aa
5041aa
diff --git a/panels/bluetooth/cc-bluetooth-panel.c b/panels/bluetooth/cc-bluetooth-panel.c
5041aa
index 9784044..cfabae8 100644
5041aa
--- a/panels/bluetooth/cc-bluetooth-panel.c
5041aa
+++ b/panels/bluetooth/cc-bluetooth-panel.c
5041aa
@@ -57,6 +57,7 @@ struct CcBluetoothPanelPrivate {
5041aa
 	gboolean             debug;
5041aa
 	GHashTable          *connecting_devices;
5041aa
 	GtkWidget           *kill_switch_header;
5041aa
+	GCancellable        *cancellable;
5041aa
 };
5041aa
 
5041aa
 static void cc_bluetooth_panel_finalize (GObject *object);
5041aa
@@ -101,6 +102,9 @@ cc_bluetooth_panel_finalize (GObject *object)
5041aa
 	bluetooth_plugin_manager_cleanup ();
5041aa
 
5041aa
 	self = CC_BLUETOOTH_PANEL (object);
5041aa
+	g_cancellable_cancel (self->priv->cancellable);
5041aa
+	g_clear_object (&self->priv->cancellable);
5041aa
+
5041aa
 	g_clear_object (&self->priv->builder);
5041aa
 	g_clear_object (&self->priv->killswitch);
5041aa
 	g_clear_object (&self->priv->client);
5041aa
@@ -165,10 +169,13 @@ connect_done (GObject      *source_object,
5041aa
 	CcBluetoothPanel *self;
5041aa
 	char *bdaddr;
5041aa
 	gboolean success;
5041aa
+	GError *error = NULL;
5041aa
 	ConnectData *data = (ConnectData *) user_data;
5041aa
 
5041aa
 	success = bluetooth_client_connect_service_finish (BLUETOOTH_CLIENT (source_object),
5041aa
-							   res, NULL);
5041aa
+							   res, &error);
5041aa
+	if (!success && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
5041aa
+		goto out;
5041aa
 
5041aa
 	self = data->self;
5041aa
 
5041aa
@@ -187,7 +194,9 @@ connect_done (GObject      *source_object,
5041aa
 	remove_connecting (self, data->bdaddr);
5041aa
 
5041aa
 	g_free (bdaddr);
5041aa
-	g_object_unref (data->self);
5041aa
+
5041aa
+out:
5041aa
+	g_clear_error (&error);
5041aa
 	g_free (data->bdaddr);
5041aa
 	g_free (data);
5041aa
 }
5041aa
@@ -221,12 +230,12 @@ switch_connected_active_changed (GtkSwitch        *button,
5041aa
 
5041aa
 	data = g_new0 (ConnectData, 1);
5041aa
 	data->bdaddr = bdaddr;
5041aa
-	data->self = g_object_ref (self);
5041aa
+	data->self = self;
5041aa
 
5041aa
 	bluetooth_client_connect_service (self->priv->client,
5041aa
 					  proxy,
5041aa
 					  gtk_switch_get_active (button),
5041aa
-					  NULL,
5041aa
+					  self->priv->cancellable,
5041aa
 					  connect_done,
5041aa
 					  data);
5041aa
 
5041aa
@@ -786,6 +795,7 @@ cc_bluetooth_panel_init (CcBluetoothPanel *self)
5041aa
 	g_resources_register (cc_bluetooth_get_resource ());
5041aa
 
5041aa
 	bluetooth_plugin_manager_init ();
5041aa
+	self->priv->cancellable = g_cancellable_new ();
5041aa
 	self->priv->killswitch = bluetooth_killswitch_new ();
5041aa
 	self->priv->client = bluetooth_client_new ();
5041aa
 	self->priv->connecting_devices = g_hash_table_new_full (g_str_hash,
5041aa
-- 
5041aa
1.8.4.2
5041aa