aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-05-10 22:35:20 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-06-09 19:34:57 +0800
commit4ee7e811f1686d7a24d951269f46dd8be682ff84 (patch)
tree3b12744a4693ca0f1bdb796ffe7139cd9b64399f /libempathy
parent88c6ee078f25bc31c60308ca927118f8b1731972 (diff)
downloadgsoc2013-empathy-4ee7e811f1686d7a24d951269f46dd8be682ff84.tar
gsoc2013-empathy-4ee7e811f1686d7a24d951269f46dd8be682ff84.tar.gz
gsoc2013-empathy-4ee7e811f1686d7a24d951269f46dd8be682ff84.tar.bz2
gsoc2013-empathy-4ee7e811f1686d7a24d951269f46dd8be682ff84.tar.lz
gsoc2013-empathy-4ee7e811f1686d7a24d951269f46dd8be682ff84.tar.xz
gsoc2013-empathy-4ee7e811f1686d7a24d951269f46dd8be682ff84.tar.zst
gsoc2013-empathy-4ee7e811f1686d7a24d951269f46dd8be682ff84.zip
Use a weak ref to remove the tpcontact from the hashtable
Conflicts: libempathy/empathy-contact.c
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-contact.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 8150e9e67..5acf2ba34 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -72,8 +72,6 @@ typedef struct {
GHashTable *location;
GeeHashSet *groups;
gchar **client_types;
-
- gboolean keep_tpcontact;
} EmpathyContactPriv;
static void contact_finalize (GObject *object);
@@ -194,9 +192,6 @@ contact_dispose (GObject *object)
if (priv->tp_contact != NULL)
{
- if (!priv->keep_tpcontact)
- g_hash_table_remove (contacts_table, priv->tp_contact);
-
g_signal_handlers_disconnect_by_func (priv->tp_contact,
tp_contact_notify_cb, object);
}
@@ -634,14 +629,27 @@ contact_set_property (GObject *object,
};
}
+static void
+remove_tp_contact (gpointer data,
+ GObject *object)
+{
+ g_hash_table_remove (contacts_table, data);
+}
+
static EmpathyContact *
empathy_contact_new (TpContact *tp_contact)
{
+ EmpathyContact *retval;
+
g_return_val_if_fail (TP_IS_CONTACT (tp_contact), NULL);
- return g_object_new (EMPATHY_TYPE_CONTACT,
+ retval = g_object_new (EMPATHY_TYPE_CONTACT,
"tp-contact", tp_contact,
NULL);
+
+ g_object_weak_ref (G_OBJECT (retval), remove_tp_contact, tp_contact);
+
+ return retval;
}
static gboolean
@@ -672,15 +680,10 @@ empathy_contact_from_tpl_contact (TpAccount *account,
if (existing_contact != NULL)
{
- EmpathyContactPriv *priv;
-
retval = g_object_new (EMPATHY_TYPE_CONTACT,
"tp-contact", empathy_contact_get_tp_contact (existing_contact),
"alias", tpl_entity_get_alias (tpl_entity),
NULL);
-
- priv = GET_PRIV (retval);
- priv->keep_tpcontact = TRUE;
}
else
{