[telepathy-mission-control/master] McdDispatcherContext: make the CDO finish before unreffing it

Simon McVittie simon.mcvittie at collabora.co.uk
Fri Jun 26 08:44:03 PDT 2009


When the McdDispatcherContext is destroyed, it's fair to say that
no more dispatching will continue, so we want to emit the necessary
signals.

This is necessary to make dispatcher/approver-fails.py pass if we don't
abort channels in order to close them.
---
 src/mcd-dispatch-operation-priv.h |    2 ++
 src/mcd-dispatch-operation.c      |   24 +++++++++++++-----------
 src/mcd-dispatcher.c              |    9 +++++++++
 3 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/src/mcd-dispatch-operation-priv.h b/src/mcd-dispatch-operation-priv.h
index 16ceb37..c216edc 100644
--- a/src/mcd-dispatch-operation-priv.h
+++ b/src/mcd-dispatch-operation-priv.h
@@ -43,6 +43,8 @@ G_GNUC_INTERNAL void _mcd_dispatch_operation_unblock_finished (
     McdDispatchOperation *self);
 G_GNUC_INTERNAL const gchar *_mcd_dispatch_operation_get_claimer (
     McdDispatchOperation *operation);
+G_GNUC_INTERNAL gboolean _mcd_dispatch_operation_finish (
+    McdDispatchOperation *operation);
 
 G_END_DECLS
 
diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index 77ae6f1..6ad1d16 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -213,11 +213,16 @@ properties_iface_init (TpSvcDBusPropertiesClass *iface, gpointer iface_data)
 #undef IMPLEMENT
 }
 
-static void
-mcd_dispatch_operation_finish (McdDispatchOperation *operation)
+gboolean
+_mcd_dispatch_operation_finish (McdDispatchOperation *operation)
 {
     McdDispatchOperationPrivate *priv = operation->priv;
 
+    if (priv->finished)
+    {
+        return FALSE;
+    }
+
     priv->finished = TRUE;
 
     if (priv->block_finished == 0)
@@ -230,6 +235,8 @@ mcd_dispatch_operation_finish (McdDispatchOperation *operation)
         DEBUG ("%s/%p not finishing just yet", priv->unique_name,
                operation);
     }
+
+    return TRUE;
 }
 
 static void
@@ -269,7 +276,7 @@ dispatch_operation_claim (TpSvcChannelDispatchOperation *self,
     priv->claimer = dbus_g_method_get_sender (context);
     tp_svc_channel_dispatch_operation_return_from_claim (context);
 
-    mcd_dispatch_operation_finish (MCD_DISPATCH_OPERATION (self));
+    _mcd_dispatch_operation_finish (MCD_DISPATCH_OPERATION (self));
 }
 
 static void
@@ -439,8 +446,6 @@ mcd_dispatch_operation_dispose (GObject *object)
 
     if (priv->lost_channels != NULL)
     {
-        g_warning ("%s still has unsignalled lost channels at dispose time",
-                   priv->unique_name);
         for (list = priv->lost_channels; list != NULL; list = list->next)
             g_object_unref (list->data);
         g_list_free (priv->lost_channels);
@@ -669,7 +674,7 @@ mcd_dispatch_operation_handle_with (McdDispatchOperation *operation,
         priv->handler = g_strdup (handler_name + MCD_CLIENT_BASE_NAME_LEN);
     }
 
-    mcd_dispatch_operation_finish (operation);
+    _mcd_dispatch_operation_finish (operation);
 }
 
 void
@@ -733,11 +738,8 @@ _mcd_dispatch_operation_lose_channel (McdDispatchOperation *self,
 
     if (self->priv->channels == NULL)
     {
-        /* no channels left, so the CDO finishes */
-        if (!self->priv->finished)
-        {
-            mcd_dispatch_operation_finish (self);
-        }
+        /* no channels left, so the CDO finishes (if it hasn't already) */
+        _mcd_dispatch_operation_finish (self);
     }
 }
 
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 6a9f105..655fdfb 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -2912,6 +2912,15 @@ mcd_dispatcher_context_unref (McdDispatcherContext * context,
             g_signal_handlers_disconnect_by_func (context->operation,
                                                   on_operation_finished,
                                                   context);
+
+            if (_mcd_dispatch_operation_finish (context->operation) &&
+                context->dispatcher->priv->operation_list_active)
+            {
+                tp_svc_channel_dispatcher_interface_operation_list_emit_dispatch_operation_finished (
+                    context->dispatcher,
+                    mcd_dispatch_operation_get_path (context->operation));
+            }
+
             g_object_unref (context->operation);
         }
         else
-- 
1.5.6.5




More information about the telepathy-commits mailing list