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-05-10 22:51:52 +0800
commit2ef5340f19483a5845976332706886d60eea38dd (patch)
tree6029591ad989ddb6307781083e18b1691ac01b0f /libempathy
parent71a3a825bab7ac73485e43fad81a466f6b9f31e4 (diff)
downloadgsoc2013-empathy-2ef5340f19483a5845976332706886d60eea38dd.tar
gsoc2013-empathy-2ef5340f19483a5845976332706886d60eea38dd.tar.gz
gsoc2013-empathy-2ef5340f19483a5845976332706886d60eea38dd.tar.bz2
gsoc2013-empathy-2ef5340f19483a5845976332706886d60eea38dd.tar.lz
gsoc2013-empathy-2ef5340f19483a5845976332706886d60eea38dd.tar.xz
gsoc2013-empathy-2ef5340f19483a5845976332706886d60eea38dd.tar.zst
gsoc2013-empathy-2ef5340f19483a5845976332706886d60eea38dd.zip
Use a weak ref to remove the tpcontact from the hashtable
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 5f45ccbf6..0cb3d0a95 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -70,8 +70,6 @@ typedef struct {
*/
GHashTable *location;
GHashTable *groups;
-
- gboolean keep_tpcontact;
} EmpathyContactPriv;
static void contact_finalize (GObject *object);
@@ -183,9 +181,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);
}
@@ -609,14 +604,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
@@ -647,15 +655,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
{