telepathy-mission-control: McdDispatchOperation: only have one lost_channel , too

Simon McVittie smcv at kemper.freedesktop.org
Tue Jul 31 03:41:21 PDT 2012


Module: telepathy-mission-control
Branch: master
Commit: 694be3e53cb8523f86afb73f3ecc0f089610375a
URL:    http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=694be3e53cb8523f86afb73f3ecc0f089610375a

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Fri Jul 20 14:03:51 2012 +0100

McdDispatchOperation: only have one lost_channel, too

https://bugs.freedesktop.org/show_bug.cgi?id=52305

---

 src/mcd-dispatch-operation.c |   43 ++++++++++++++---------------------------
 1 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index 9c2ca56..ac036f0 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -198,9 +198,9 @@ struct _McdDispatchOperationPrivate
 
     /* Owned McdChannel we're dispatching */
     McdChannel *channel;
-    /* Owned McdChannels for which we can't emit ChannelLost yet, in
-     * reverse chronological order */
-    GList *lost_channels;
+    /* If non-NULL, we have lost the McdChannel but can't emit
+     * ChannelLost yet */
+    McdChannel *lost_channel;
 
     /* If TRUE, either the channel being dispatched was requested, or it
      * was pre-approved by being returned as a response to another request,
@@ -1311,7 +1311,6 @@ static void
 mcd_dispatch_operation_dispose (GObject *object)
 {
     McdDispatchOperationPrivate *priv = MCD_DISPATCH_OPERATION_PRIV (object);
-    GList *list;
 
     tp_clear_object (&priv->plugin_api);
     tp_clear_object (&priv->successful_handler);
@@ -1322,16 +1321,8 @@ mcd_dispatch_operation_dispose (GObject *object)
             mcd_dispatch_operation_channel_aborted_cb, object);
     }
 
-    if (priv->lost_channels != NULL)
-    {
-        for (list = priv->lost_channels; list != NULL; list = list->next)
-            g_object_unref (list->data);
-
-        tp_clear_pointer (&priv->lost_channels, g_list_free);
-    }
-
     tp_clear_object (&priv->channel);
-    tp_clear_object (&priv->connection);
+    tp_clear_object (&priv->lost_channel);
     tp_clear_object (&priv->account);
     tp_clear_object (&priv->handler_map);
     tp_clear_object (&priv->client_registry);
@@ -1643,9 +1634,8 @@ _mcd_dispatch_operation_lose_channel (McdDispatchOperation *self,
                "%" G_GSIZE_FORMAT " approvers",
                self->priv->unique_name, self, object_path,
                self->priv->observers_pending, self->priv->ado_pending);
-        self->priv->lost_channels =
-            g_list_prepend (self->priv->lost_channels,
-                            g_object_ref (channel));
+        g_assert (self->priv->lost_channel == NULL);
+        self->priv->lost_channel = g_object_ref (channel);
     }
     else
     {
@@ -1673,28 +1663,26 @@ _mcd_dispatch_operation_check_finished (McdDispatchOperation *self)
 {
     if (mcd_dispatch_operation_may_signal_finished (self))
     {
-        GList *lost_channels;
+        McdChannel *lost_channel = self->priv->lost_channel;
 
-        /* get the lost channels into chronological order, and steal them from
-         * the object*/
-        lost_channels = g_list_reverse (self->priv->lost_channels);
-        self->priv->lost_channels = NULL;
+        /* steal it */
+        self->priv->lost_channel = NULL;
 
-        while (lost_channels != NULL)
+        if (lost_channel != NULL)
         {
-            McdChannel *channel = lost_channels->data;
-            const gchar *object_path = mcd_channel_get_object_path (channel);
+            const gchar *object_path = mcd_channel_get_object_path (
+                lost_channel);
 
             if (object_path == NULL)
             {
                 /* This shouldn't happen, but McdChannel is twisty enough
                  * that I can't be sure */
                 g_critical ("McdChannel has already lost its TpChannel: %p",
-                    channel);
+                    lost_channel);
             }
             else
             {
-                const GError *error = mcd_channel_get_error (channel);
+                const GError *error = mcd_channel_get_error (lost_channel);
                 gchar *error_name = _mcd_build_error_string (error);
 
                 DEBUG ("%s/%p losing channel %s: %s: %s",
@@ -1705,8 +1693,7 @@ _mcd_dispatch_operation_check_finished (McdDispatchOperation *self)
                 g_free (error_name);
             }
 
-            g_object_unref (channel);
-            lost_channels = g_list_delete_link (lost_channels, lost_channels);
+            g_object_unref (lost_channel);
         }
 
         if (self->priv->result != NULL)



More information about the telepathy-commits mailing list