summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2014-04-06 18:01:18 -0400
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-17 14:22:29 +0100
commite9174fe566a8fbd4c627ff574c594d6466c6a20d (patch)
tree59e150c34d37e8e7cc7a3dcecf0ecc27c334a15a
parent0b57d9e66ca25a5e6684751a23a88b91e719e3c6 (diff)
Tests: fix TpChannelManager implementations
They should remove the channel from their internal table before emitting channel-closed. That way foreach_channel() won't return closed channel from within channel-closed cb. Also fix a crash in example call-manager.c if foreach_channel() is called after close_all()
-rw-r--r--examples/cm/call/call-manager.c9
-rw-r--r--examples/cm/channelspecific/room-manager.c6
-rw-r--r--examples/cm/echo-message-parts/im-manager.c6
-rw-r--r--telepathy-glib/simple-password-manager.c4
-rw-r--r--tests/lib/echo-im-manager.c6
5 files changed, 17 insertions, 14 deletions
diff --git a/examples/cm/call/call-manager.c b/examples/cm/call/call-manager.c
index fe7443344..9ffa40d95 100644
--- a/examples/cm/call/call-manager.c
+++ b/examples/cm/call/call-manager.c
@@ -292,6 +292,9 @@ example_call_manager_foreach_channel (TpChannelManager *iface,
GHashTableIter iter;
gpointer chan;
+ if (self->priv->channels == NULL)
+ return;
+
g_hash_table_iter_init (&iter, self->priv->channels);
while (g_hash_table_iter_next (&iter, &chan, NULL))
@@ -302,11 +305,11 @@ static void
channel_closed_cb (ExampleCallChannel *chan,
ExampleCallManager *self)
{
- tp_channel_manager_emit_channel_closed_for_object (
- TP_CHANNEL_MANAGER (self), TP_EXPORTABLE_CHANNEL (chan));
-
if (self->priv->channels != NULL)
g_hash_table_remove (self->priv->channels, chan);
+
+ tp_channel_manager_emit_channel_closed_for_object (
+ TP_CHANNEL_MANAGER (self), TP_EXPORTABLE_CHANNEL (chan));
}
static ExampleCallChannel *
diff --git a/examples/cm/channelspecific/room-manager.c b/examples/cm/channelspecific/room-manager.c
index 44f46f46c..5127dd8bf 100644
--- a/examples/cm/channelspecific/room-manager.c
+++ b/examples/cm/channelspecific/room-manager.c
@@ -210,9 +210,6 @@ static void
channel_closed_cb (ExampleCSHRoomChannel *chan,
ExampleCSHRoomManager *self)
{
- tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self),
- TP_EXPORTABLE_CHANNEL (chan));
-
if (self->priv->channels != NULL)
{
TpHandle handle;
@@ -223,6 +220,9 @@ channel_closed_cb (ExampleCSHRoomChannel *chan,
g_hash_table_remove (self->priv->channels, GUINT_TO_POINTER (handle));
}
+
+ tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self),
+ TP_EXPORTABLE_CHANNEL (chan));
}
static void
diff --git a/examples/cm/echo-message-parts/im-manager.c b/examples/cm/echo-message-parts/im-manager.c
index a826aa418..07cef8224 100644
--- a/examples/cm/echo-message-parts/im-manager.c
+++ b/examples/cm/echo-message-parts/im-manager.c
@@ -193,9 +193,6 @@ static void
channel_closed_cb (ExampleEcho2Channel *chan,
ExampleEcho2ImManager *self)
{
- tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self),
- TP_EXPORTABLE_CHANNEL (chan));
-
if (self->priv->channels != NULL)
{
TpHandle handle;
@@ -219,6 +216,9 @@ channel_closed_cb (ExampleEcho2Channel *chan,
TP_EXPORTABLE_CHANNEL (chan), NULL);
}
}
+
+ tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self),
+ TP_EXPORTABLE_CHANNEL (chan));
}
static void
diff --git a/telepathy-glib/simple-password-manager.c b/telepathy-glib/simple-password-manager.c
index 7e38d0ebc..3d38cfdf3 100644
--- a/telepathy-glib/simple-password-manager.c
+++ b/telepathy-glib/simple-password-manager.c
@@ -300,10 +300,10 @@ static void
tp_simple_password_manager_channel_closed_cb (GObject *chan,
TpSimplePasswordManager *manager)
{
+ tp_clear_object (&manager->priv->channel);
+
tp_channel_manager_emit_channel_closed_for_object (
TP_CHANNEL_MANAGER (manager), TP_EXPORTABLE_CHANNEL (chan));
-
- tp_clear_object (&manager->priv->channel);
}
static void
diff --git a/tests/lib/echo-im-manager.c b/tests/lib/echo-im-manager.c
index 71afd6db6..6b9ebe407 100644
--- a/tests/lib/echo-im-manager.c
+++ b/tests/lib/echo-im-manager.c
@@ -195,9 +195,6 @@ static void
channel_closed_cb (TpTestsEchoChannel *chan,
TpTestsEchoImManager *self)
{
- tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self),
- TP_EXPORTABLE_CHANNEL (chan));
-
if (self->priv->channels != NULL)
{
TpHandle handle;
@@ -221,6 +218,9 @@ channel_closed_cb (TpTestsEchoChannel *chan,
TP_EXPORTABLE_CHANNEL (chan), NULL);
}
}
+
+ tp_channel_manager_emit_channel_closed_for_object (TP_CHANNEL_MANAGER (self),
+ TP_EXPORTABLE_CHANNEL (chan));
}
static void