summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-07-20 12:29:15 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-07-20 12:29:15 +0100
commit4cbf379a57b28638ff30920757a712a098bced31 (patch)
treef6c21a12a48a07b5b3aed84879a6aca71ec7d9bc
parent192a79835209c1f984117085fdd2183cc4ecb7c9 (diff)
McdDispatchOperation: only have one lost_channel, toomission-impossible
-rw-r--r--src/mcd-dispatch-operation.c42
1 files changed, 15 insertions, 27 deletions
diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index 970caa87..492a527a 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,
@@ -1302,7 +1302,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);
@@ -1314,14 +1313,7 @@ mcd_dispatch_operation_dispose (GObject *object)
}
tp_clear_object (&priv->channel);
- 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->lost_channel);
tp_clear_object (&priv->tp_conn);
tp_clear_object (&priv->account);
tp_clear_object (&priv->handler_map);
@@ -1651,9 +1643,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
{
@@ -1681,28 +1672,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",
@@ -1713,8 +1702,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)