[telepathy-account-widgets] Fix GetProtocolsData leak



commit 6a4a30ff016b31cf366daa1e1854e20da45bf9fa
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Mon Jul 27 23:30:24 2015 +0200

    Fix GetProtocolsData leak
    
    A GetProtocolsData instance gets associated with a GSimpleAsyncResult in
    tpaw_protocol_get_all_async() using
    g_simple_async_result_set_op_res_gpointer(). A GDestroyNotify is set so
    that the GetProtocolsData instance is freed when the GSimpleAsyncResult
    is freed.
    However, this is not working as expected as the GetProtocolsData
    instance is keeping a reference on the GSimpleAsyncResult it's
    associated with, which creates a circular reference and causes the
    GetProtocolsData instance to never be freed.
    
    This commit drops the reference on the GSimpleAsyncResult instance owned
    by the GetProtocolsData instance as soon as it's no longer needed so
    that the GSimpleAsyncResult can be disposed, which triggers the
    destruction of the GetProtocolsData too.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=752938

 tp-account-widgets/tpaw-protocol.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/tp-account-widgets/tpaw-protocol.c b/tp-account-widgets/tpaw-protocol.c
index af8bb29..51d7a46 100644
--- a/tp-account-widgets/tpaw-protocol.c
+++ b/tp-account-widgets/tpaw-protocol.c
@@ -484,8 +484,7 @@ cms_prepare_cb (GObject *source,
   if (!tpaw_connection_managers_prepare_finish (cms, result, &error))
     {
       g_simple_async_result_take_error (data->result, error);
-      g_simple_async_result_complete_in_idle (data->result);
-      return;
+      goto out;
     }
 
   for (l = tpaw_connection_managers_get_cms (cms); l != NULL; l = l->next)
@@ -494,13 +493,14 @@ cms_prepare_cb (GObject *source,
   data->protocols = g_list_sort (data->protocols,
       (GCompareFunc) protocol_sort_func);
 
+out:
   g_simple_async_result_complete_in_idle (data->result);
+  g_object_unref (data->result);
 }
 
 static void
 destroy_get_protocols_data (GetProtocolsData *data)
 {
-  g_object_unref (data->result);
   g_hash_table_unref (data->seen_protocols);
   g_list_free_full (data->protocols, g_object_unref);
   g_slice_free (GetProtocolsData, data);


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