]> git.0d.be Git - empathy.git/commitdiff
ref group when async calls are in flight to avoid destroying the object
authorXavier Claessens <xclaesse@gmail.com>
Sat, 29 Sep 2007 13:31:57 +0000 (13:31 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Sat, 29 Sep 2007 13:31:57 +0000 (13:31 +0000)
2007-09-29  Xavier Claessens  <xclaesse@gmail.com>

* libempathy/empathy-tp-group.c: ref group when async calls are in
flight to avoid destroying the object before receiving the reply.
* libempathy/empathy-utils.c: Unref the group to not leak it.

svn path=/trunk/; revision=341

ChangeLog
libempathy/empathy-tp-group.c
libempathy/empathy-utils.c

index fa0a635d21a48c561ccfc25e13ce6c7d9c680a89..7582c574ca1d8c3d71369bfb0a50dceca47014e4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-09-29  Xavier Claessens  <xclaesse@gmail.com>
+
+       * libempathy/empathy-tp-group.c: ref group when async calls are in
+       flight to avoid destroying the object before receiving the reply.
+       * libempathy/empathy-utils.c: Unref the group to not leak it.
+
 2007-09-29  Xavier Claessens  <xclaesse@gmail.com>
 
        * libempathy/empathy-contact-factory.c: Refcount
index dbc2d228e07a6f19362ca8b12746fc75476c7c48..f6f8004cce00a988246ad13fab83e351371a625f 100644 (file)
@@ -358,6 +358,7 @@ tp_group_get_members_cb (DBusGProxy *proxy,
        if (error) {
                empathy_debug (DEBUG_DOMAIN, "Failed to get members: %s",
                               error->message);
+               g_object_unref (group);
                return;
        }
 
@@ -372,6 +373,7 @@ tp_group_get_members_cb (DBusGProxy *proxy,
                                     group);
 
        g_array_free (handles, TRUE);
+       g_object_unref (group);
 }
 
 static void
@@ -388,6 +390,7 @@ tp_group_get_local_pending_cb (DBusGProxy *proxy,
        if (error) {
                empathy_debug (DEBUG_DOMAIN, "Failed to get local pendings: %s",
                               error->message);
+               g_object_unref (group);
                return;
        }
 
@@ -420,6 +423,7 @@ tp_group_get_local_pending_cb (DBusGProxy *proxy,
        }
        g_ptr_array_free (array, TRUE);
        g_array_free (handles, TRUE);
+       g_object_unref (group);
 }
 
 static void
@@ -434,6 +438,7 @@ tp_group_get_remote_pending_cb (DBusGProxy *proxy,
        if (error) {
                empathy_debug (DEBUG_DOMAIN, "Failed to get remote pendings: %s",
                               error->message);
+               g_object_unref (group);
                return;
        }
 
@@ -448,6 +453,7 @@ tp_group_get_remote_pending_cb (DBusGProxy *proxy,
                                     group);
 
        g_array_free (handles, TRUE);
+       g_object_unref (group);
 }
 
 static void
@@ -455,6 +461,8 @@ tp_group_finalize (GObject *object)
 {
        EmpathyTpGroupPriv *priv = GET_PRIV (object);
 
+       empathy_debug (DEBUG_DOMAIN, "finalize: %p");
+
        tp_group_disconnect (EMPATHY_TP_GROUP (object));
 
        if (priv->tp_chan) {
@@ -590,13 +598,13 @@ empathy_tp_group_new (McAccount *account,
 
        tp_chan_iface_group_get_members_async (priv->group_iface,
                                               tp_group_get_members_cb,
-                                              group);
+                                              g_object_ref (group));
        tp_chan_iface_group_get_local_pending_members_with_info_async (priv->group_iface,
                                                                       tp_group_get_local_pending_cb,
-                                                                      group);
+                                                                      g_object_ref (group));
        tp_chan_iface_group_get_remote_pending_members_async (priv->group_iface,
                                                              tp_group_get_remote_pending_cb,
-                                                             group);
+                                                             g_object_ref (group));
 
        return group;
 }
index f33d83e48b122232ab52a275c580dbf5b27971ee..e90521b05984591e03702c2a4eafd72f1490c904 100644 (file)
@@ -509,14 +509,10 @@ empathy_call_contact (EmpathyContact *contact)
                                TP_HANDLE_TYPE_NONE,
                                0);
 
-       /* FIXME: group is leaked, we can't unref it directly because
-        * _add_member is async so we have to wait for it to return before
-        * finalizing the group. I think EmpathyTpGroup should ref itself
-        * when it does async calls to avoid finalizing when there is calls
-        * in fligth like that we could unref it here. */
        group = empathy_tp_group_new (account, new_chan);
        empathy_tp_group_add_member (group, contact, "");
 
+       g_object_unref (group);
        g_object_unref (mc);
        g_object_unref (tp_conn);
        g_object_unref (new_chan);