diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2010-07-06 21:40:35 +0800 |
---|---|---|
committer | Travis Reitter <treitter@gmail.com> | 2010-07-21 07:12:36 +0800 |
commit | e25fa2252ec8b46a9584f294d8604dee86ff7a38 (patch) | |
tree | 9294a9ab47fa8987fee86f584ff97af3c39e21a9 /libempathy/empathy-individual-manager.c | |
parent | 1acf1e0f3b5686b95f1b0787a5308e0a6298eb08 (diff) | |
download | gsoc2013-empathy-e25fa2252ec8b46a9584f294d8604dee86ff7a38.tar gsoc2013-empathy-e25fa2252ec8b46a9584f294d8604dee86ff7a38.tar.gz gsoc2013-empathy-e25fa2252ec8b46a9584f294d8604dee86ff7a38.tar.bz2 gsoc2013-empathy-e25fa2252ec8b46a9584f294d8604dee86ff7a38.tar.lz gsoc2013-empathy-e25fa2252ec8b46a9584f294d8604dee86ff7a38.tar.xz gsoc2013-empathy-e25fa2252ec8b46a9584f294d8604dee86ff7a38.tar.zst gsoc2013-empathy-e25fa2252ec8b46a9584f294d8604dee86ff7a38.zip |
Hold a reference to the contact we're adding as an individual
In empathy_individual_manager_add_from_contact(), we must hold a reference to
the contact we're adding throughout the entire async process, or the TpHandle
which represents the contact could get unreffed and destroyed. This causes
the new contact to get lost.
Diffstat (limited to 'libempathy/empathy-individual-manager.c')
-rw-r--r-- | libempathy/empathy-individual-manager.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c index db994327f..183996a3d 100644 --- a/libempathy/empathy-individual-manager.c +++ b/libempathy/empathy-individual-manager.c @@ -261,18 +261,21 @@ aggregator_add_persona_from_details_cb (GObject *source, GAsyncResult *result, gpointer user_data) { - EmpathyIndividualManager *self = EMPATHY_INDIVIDUAL_MANAGER (user_data); - EmpathyIndividualManagerPriv *priv = GET_PRIV (self); + FolksIndividualAggregator *aggregator = FOLKS_INDIVIDUAL_AGGREGATOR (source); + EmpathyContact *contact = EMPATHY_CONTACT (user_data); FolksPersona *persona; GError *error = NULL; persona = folks_individual_aggregator_add_persona_from_details_finish ( - priv->aggregator, result, &error); + aggregator, result, &error); if (error != NULL) { g_warning ("failed to add individual from contact: %s", error->message); g_clear_error (&error); } + + /* We can unref the contact now */ + g_object_unref (contact); } void @@ -289,6 +292,10 @@ empathy_individual_manager_add_from_contact (EmpathyIndividualManager *self, priv = GET_PRIV (self); + /* We need to ref the contact since otherwise its linked TpHandle will be + * destroyed. */ + g_object_ref (contact); + DEBUG (G_STRLOC ": adding individual from contact %s (%s)", empathy_contact_get_id (contact), empathy_contact_get_name (contact)); @@ -301,7 +308,7 @@ empathy_individual_manager_add_from_contact (EmpathyIndividualManager *self, folks_individual_aggregator_add_persona_from_details ( priv->aggregator, NULL, "telepathy", store_id, details, - aggregator_add_persona_from_details_cb, self); + aggregator_add_persona_from_details_cb, contact); g_hash_table_destroy (details); } |