summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-07-20 12:13:30 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-07-20 14:28:38 +0100
commit80ea4690cef4b6e2e4509df7fc9040b66ff93faf (patch)
tree291179e91e6e1b7c7690845fac3b29d376c28e6d
parentb8427349b001b799b9b0dfd63686cc80c2625722 (diff)
_mcd_dispatch_operation_dup_channels: turn into dup_channel, singular
https://bugs.freedesktop.org/show_bug.cgi?id=52305
-rw-r--r--src/mcd-dispatch-operation-priv.h2
-rw-r--r--src/mcd-dispatch-operation.c17
-rw-r--r--src/mcd-dispatcher.c13
3 files changed, 14 insertions, 18 deletions
diff --git a/src/mcd-dispatch-operation-priv.h b/src/mcd-dispatch-operation-priv.h
index 23ddb5d3..a8611715 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 4559c87d..d18f3ccd 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 07d6f9af..ce3292d3 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)