[telepathy-gabble/master] search-channel: destroy the channels hash table when finalizing
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Wed Aug 26 08:58:40 PDT 2009
That way we don't have to check if the hash table still exist or not.
---
src/search-manager.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/search-manager.c b/src/search-manager.c
index 9872f49..ce3b559 100644
--- a/src/search-manager.c
+++ b/src/search-manager.c
@@ -97,9 +97,6 @@ gabble_search_manager_close_all (GabbleSearchManager *self)
{
GList *chans, *l;
- if (self->priv->channels == NULL)
- return;
-
DEBUG ("closing channels");
/* We can't use a GHashTableIter as closing the channel while remove it from
@@ -112,8 +109,6 @@ gabble_search_manager_close_all (GabbleSearchManager *self)
gabble_search_channel_close (chan);
}
- g_hash_table_destroy (self->priv->channels);
- self->priv->channels = NULL;
g_list_free (chans);
/* base-connection cancels all the pending requests when disconnecting so we
@@ -236,6 +231,10 @@ gabble_search_manager_finalize (GObject *object)
g_free (priv->default_jud);
+ /* close_all removed all the channels from the hash table */
+ g_assert_cmpuint (g_hash_table_size (priv->channels), ==, 0);
+ g_hash_table_destroy (priv->channels);
+
if (G_OBJECT_CLASS (gabble_search_manager_parent_class)->finalize)
G_OBJECT_CLASS (gabble_search_manager_parent_class)->finalize (object);
}
@@ -352,8 +351,7 @@ static void
remove_search_channel (GabbleSearchManager *self,
GabbleSearchChannel *chan)
{
- if (self->priv->channels != NULL)
- g_hash_table_remove (self->priv->channels, chan);
+ g_hash_table_remove (self->priv->channels, chan);
}
static void
--
1.5.6.5
More information about the telepathy-commits
mailing list