File 0001-tp_list_connection_managers_async-terminate-properly.patch of Package telepathy-glib
From e8b9fc31f0f4fee539dd6248bde70c2c505a6df4 Mon Sep 17 00:00:00 2001
From: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Date: Mon, 17 Mar 2014 16:46:44 +0100
Subject: [PATCH 1/2] connection-manager: factor out all_cms_prepared()
---
telepathy-glib/connection-manager.c | 46 +++++++++++++++++++++----------------
1 file changed, 26 insertions(+), 20 deletions(-)
Index: telepathy-glib-0.22.1/telepathy-glib/connection-manager.c
===================================================================
--- telepathy-glib-0.22.1.orig/telepathy-glib/connection-manager.c
+++ telepathy-glib-0.22.1/telepathy-glib/connection-manager.c
@@ -1788,6 +1788,31 @@ list_context_unref (_ListContext *list_c
g_slice_free (_ListContext, list_context);
}
+ static void
+all_cms_prepared (_ListContext *list_context)
+{
+ TpConnectionManager **cms;
+ guint n_cms = list_context->arr->len;
+
+ DEBUG ("We've prepared as many as possible of %u CMs", n_cms);
+
+ g_assert (list_context->callback != NULL);
+
+ g_ptr_array_add (list_context->arr, NULL);
+ cms = (TpConnectionManager **) list_context->arr->pdata;
+
+ /* If we never had a weak object anyway, call the callback.
+ * If we had a weak object when we started, only call the callback
+ * if it hasn't died yet. */
+ if (!list_context->had_weak_object || list_context->weak_object != NULL)
+ {
+ list_context->callback (cms, n_cms, NULL, list_context->user_data,
+ list_context->weak_object);
+ }
+
+ list_context->callback = NULL;
+}
+
static void
tp_list_connection_managers_cm_prepared (GObject *source G_GNUC_UNUSED,
GAsyncResult *result G_GNUC_UNUSED,
@@ -1800,24 +1825,7 @@ tp_list_connection_managers_cm_prepared
if ((--list_context->cms_to_ready) == 0)
{
- TpConnectionManager **cms;
- guint n_cms = list_context->arr->len;
-
- g_assert (list_context->callback != NULL);
-
- g_ptr_array_add (list_context->arr, NULL);
- cms = (TpConnectionManager **) list_context->arr->pdata;
-
- /* If we never had a weak object anyway, call the callback.
- * If we had a weak object when we started, only call the callback
- * if it hasn't died yet. */
- if (!list_context->had_weak_object || list_context->weak_object != NULL)
- {
- list_context->callback (cms, n_cms, NULL, list_context->user_data,
- list_context->weak_object);
- }
-
- list_context->callback = NULL;
+ all_cms_prepared (list_context);
}
list_context_unref (list_context);
@@ -1877,6 +1885,12 @@ tp_list_connection_managers_got_names (T
list_context->cms_to_ready = list_context->arr->len;
list_context->refcount += list_context->cms_to_ready;
+ if (list_context->cms_to_ready == 0)
+ {
+ all_cms_prepared (list_context);
+ return;
+ }
+
for (i = 0; i < list_context->cms_to_ready; i++)
{
TpConnectionManager *cm = g_ptr_array_index (list_context->arr, i);