telepathy-mission-control: _mcd_dispatch_operation_dup_channels: turn into dup_channel, singular

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


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

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Fri Jul 20 12:13:30 2012 +0100

_mcd_dispatch_operation_dup_channels: turn into dup_channel, singular

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

---

 src/mcd-dispatch-operation-priv.h |    2 +-
 src/mcd-dispatch-operation.c      |   17 ++++++++++-------
 src/mcd-dispatcher.c              |   13 +++----------
 3 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/src/mcd-dispatch-operation-priv.h b/src/mcd-dispatch-operation-priv.h
index 23ddb5d..a861171 100644
--- a/src/mcd-dispatch-operation-priv.h
+++ b/src/mcd-dispatch-operation-priv.h
@@ -77,7 +77,7 @@ G_GNUC_INTERNAL gboolean _mcd_dispatch_operation_has_channel (
     McdDispatchOperation *self, McdChannel *channel);
 G_GNUC_INTERNAL McdChannel *_mcd_dispatch_operation_peek_channel (
     McdDispatchOperation *self);
-G_GNUC_INTERNAL GList *_mcd_dispatch_operation_dup_channels (
+G_GNUC_INTERNAL McdChannel *_mcd_dispatch_operation_dup_channel (
     McdDispatchOperation *self);
 
 G_GNUC_INTERNAL gboolean _mcd_dispatch_operation_is_finished (
diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index 4559c87..d18f3cc 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -1897,15 +1897,18 @@ _mcd_dispatch_operation_peek_channel (McdDispatchOperation *self)
     return self->priv->channels->data;
 }
 
-GList *
-_mcd_dispatch_operation_dup_channels (McdDispatchOperation *self)
+McdChannel *
+_mcd_dispatch_operation_dup_channel (McdDispatchOperation *self)
 {
-    GList *copy;
-
     g_return_val_if_fail (MCD_IS_DISPATCH_OPERATION (self), NULL);
-    copy = g_list_copy (self->priv->channels);
-    g_list_foreach (copy, (GFunc) g_object_ref, NULL);
-    return copy;
+
+    g_assert (self->priv->channels == NULL ||
+              self->priv->channels->next == NULL);
+
+    if (self->priv->channels != NULL)
+        return g_object_ref (self->priv->channels->data);
+
+    return NULL;
 }
 
 static void
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 07d6f9a..ce3292d 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -293,25 +293,18 @@ _mcd_dispatcher_enter_state_machine (McdDispatcher *dispatcher,
     {
         GError error = { TP_ERROR, TP_ERROR_CANCELLED,
             "Channel request cancelled" };
-        GList *list;
+        McdChannel *cancelled;
 
-        /* make a temporary copy, which is destroyed during the loop -
-         * otherwise we'll be trying to iterate over the list at the same time
-         * that mcd_mission_abort results in modifying it, which would be
-         * bad */
-        list = _mcd_dispatch_operation_dup_channels (operation);
+        cancelled = _mcd_dispatch_operation_dup_channel (operation);
 
-        while (list != NULL)
+        if (cancelled != NULL)
         {
-            McdChannel *cancelled = MCD_CHANNEL (list->data);
-
             if (mcd_channel_get_error (cancelled) == NULL)
                 mcd_channel_take_error (cancelled, g_error_copy (&error));
 
             _mcd_channel_undispatchable (cancelled);
 
             g_object_unref (cancelled);
-            list = g_list_delete_link (list, list);
         }
     }
     else if (_mcd_dispatch_operation_peek_channel (operation) == NULL)



More information about the telepathy-commits mailing list