[Telepathy-commits] [telepathy-gabble/master] GabbleDisco: temporarily ref the disco object while calling out to user code

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Aug 19 10:52:05 PDT 2008


20080501173153-53eee-48e86d834e19bce2deae9c1c58fa47bdf665c12d.gz
---
 src/disco.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/disco.c b/src/disco.c
index 11d358d..4dd00c1 100644
--- a/src/disco.c
+++ b/src/disco.c
@@ -293,6 +293,7 @@ static gboolean
 timeout_request (gpointer data)
 {
   GabbleDiscoRequest *request = (GabbleDiscoRequest*) data;
+  GabbleDisco *disco;
   GError *err /* doesn't need initializing */;
   g_return_val_if_fail (data != NULL, FALSE);
 
@@ -300,12 +301,20 @@ timeout_request (gpointer data)
       "Request for %s on %s timed out",
       (request->type == GABBLE_DISCO_TYPE_INFO)?"info":"items",
       request->jid);
+
+  /* Temporarily ref the disco object to avoid crashing if the callback
+   * destroys us (as seen in test-disco-no-reply.py) */
+  disco = g_object_ref (request->disco);
+
   (request->callback)(request->disco, request, request->jid, request->node,
                       NULL, err, request->user_data);
   g_error_free (err);
 
   request->timer_id = 0;
   delete_request (request);
+
+  g_object_unref (disco);
+
   return FALSE;
 }
 
-- 
1.5.6.3




More information about the Telepathy-commits mailing list