[next] telepathy-glib: Tests: fix TpChannelManager implementations
Simon McVittie
smcv at kemper.freedesktop.org
Wed May 7 02:18:23 PDT 2014
Module: telepathy-glib
Branch: next
Commit: 17d2fedb12e293560b7f8a1817883a233361ed13
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=17d2fedb12e293560b7f8a1817883a233361ed13
Author: Xavier Claessens <xavier.claessens at collabora.com>
Date: Sun Apr 6 18:01:18 2014 -0400
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()
Reviewed-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77189
---
examples/cm/call/call-manager.c | 9 ++++++---
examples/cm/channelspecific/room-manager.c | 6 +++---
examples/cm/echo-message-parts/im-manager.c | 6 +++---
telepathy-glib/simple-password-manager.c | 4 ++--
tests/lib/echo-im-manager.c | 6 +++---
5 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/examples/cm/call/call-manager.c b/examples/cm/call/call-manager.c
index fe74433..9ffa40d 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 44f46f4..5127dd8 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 a826aa4..07cef82 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 7e38d0e..3d38cfd 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 71afd6d..6b9ebe4 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
More information about the telepathy-commits
mailing list