[telepathy-mission-control/master] McdDispatcher: always keep the dispatcher context ref'd until ready-to-dispatch

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Nov 2 06:41:41 PST 2009


---
 src/mcd-dispatcher.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index c93388c..62e3018 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -1165,12 +1165,13 @@ static void
 mcd_dispatcher_op_ready_to_dispatch_cb (McdDispatchOperation *operation,
                                         McdDispatcherContext *context)
 {
+    g_signal_handlers_disconnect_by_func (operation,
+        mcd_dispatcher_op_ready_to_dispatch_cb, context);
+
     /* This is emitted when the HandleWith() or Claimed() are invoked on the
      * CDO: according to which of these have happened, we run the choosen
      * handler or we don't. */
 
-    mcd_dispatcher_context_ref (context, "CTXREF15");
-
     /* Because of our calls to _mcd_dispatch_operation_block_finished,
      * this cannot happen until all observers and all approvers have
      * returned from ObserveChannels or AddDispatchOperation, respectively. */
@@ -1255,11 +1256,13 @@ _mcd_dispatcher_enter_state_machine (McdDispatcher *dispatcher,
 
         g_signal_connect (context->operation, "finished",
                           G_CALLBACK (on_operation_finished), dispatcher);
-        g_signal_connect (context->operation, "ready-to-dispatch",
-                          G_CALLBACK (mcd_dispatcher_op_ready_to_dispatch_cb),
-                          context);
     }
 
+    mcd_dispatcher_context_ref (context, "CTXREF15");
+    g_signal_connect (context->operation, "ready-to-dispatch",
+                      G_CALLBACK (mcd_dispatcher_op_ready_to_dispatch_cb),
+                      context);
+
     DEBUG ("entering state machine for context %p", context);
 
     sp_timestamp ("invoke internal filters");
@@ -1919,9 +1922,6 @@ mcd_dispatcher_context_unref (McdDispatcherContext * context,
         g_signal_handlers_disconnect_by_func (context->operation,
             mcd_dispatcher_run_handlers, context);
 
-        g_signal_handlers_disconnect_by_func (context->operation,
-            mcd_dispatcher_op_ready_to_dispatch_cb, context);
-
         /* may emit finished */
         if (_mcd_dispatch_operation_finish (context->operation))
         {
-- 
1.5.6.5




More information about the telepathy-commits mailing list