gnome-bluetooth r505 - trunk/common



Author: hadess
Date: Thu Mar 19 18:38:45 2009
New Revision: 505
URL: http://svn.gnome.org/viewvc/gnome-bluetooth?rev=505&view=rev

Log:
Don't crash when setting up an AudioSink fails

And don't try to connect to the Headset if AudioSink
was successful.



Modified:
   trunk/common/bluetooth-client.c

Modified: trunk/common/bluetooth-client.c
==============================================================================
--- trunk/common/bluetooth-client.c	(original)
+++ trunk/common/bluetooth-client.c	Thu Mar 19 18:38:45 2009
@@ -1344,26 +1344,33 @@
 {
 	ConnectData *conndata = user_data;
 	GError *error = NULL;
+	gboolean got_error;
 
-	dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_INVALID);
+	got_error = dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_INVALID);
 
 	if (error != NULL)
 		g_error_free(error);
 
-	if (conndata->did_audiosink) {
+	if (conndata->did_audiosink || got_error == FALSE) {
 		if (conndata->func)
 			conndata->func(conndata->data);
 
 		g_object_unref(proxy);
 	} else {
 		DBusGProxy *new_proxy;
+		ConnectData *new_conndata;
+
+		/* the conndata will be freed when we return */
+		new_conndata = g_new0 (ConnectData, 1);
+		new_conndata->func = conndata->func;
+		new_conndata->data = conndata->data;
+		new_conndata->did_audiosink = TRUE;
 
-		conndata->did_audiosink = TRUE;
 		new_proxy = dbus_g_proxy_new_from_proxy(proxy,
 						    BLUEZ_INPUT_HEADSET, NULL);
 		g_object_unref (proxy);
 		call = dbus_g_proxy_begin_call(new_proxy, "Connect",
-					       connect_audio_callback, conndata, g_free,
+					       connect_audio_callback, new_conndata, g_free,
 					       G_TYPE_INVALID);
 	}
 }



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