[telepathy-mission-control/master] Context cannot be finished twice

Alberto Mardegan alberto.mardegan at nokia.com
Mon Apr 20 04:14:19 PDT 2009


Make sure that the dispatch-finished (and the unreferencing of the relative
context) happens only once per context.
---
 src/mcd-dispatcher.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index e8ddc9d..ba835ae 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -88,6 +88,8 @@ struct _McdDispatcherContext
 {
     gint ref_count;
 
+    guint finished : 1;
+
     /* If this flag is TRUE, dispatching must be cancelled ASAP */
     guint cancelled : 1;
 
@@ -311,6 +313,12 @@ mcd_dispatcher_context_handler_done (McdDispatcherContext *context)
     GList *list;
     gint channels_left = 0;
 
+    if (context->finished)
+    {
+        DEBUG ("context %p is already finished", context);
+        return;
+    }
+
     for (list = context->channels; list != NULL; list = list->next)
     {
         McdChannel *channel = MCD_CHANNEL (list->data);
@@ -327,6 +335,7 @@ mcd_dispatcher_context_handler_done (McdDispatcherContext *context)
     DEBUG ("%d channels still dispatching", channels_left);
     if (channels_left == 0)
     {
+        context->finished = TRUE;
         g_signal_emit (context->dispatcher,
                        signals[DISPATCH_COMPLETED], 0, context);
         mcd_dispatcher_context_unref (context);
-- 
1.5.6.5




More information about the telepathy-commits mailing list