aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimo.cecchi@collabora.co.uk>2009-05-23 22:08:05 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2009-06-01 23:53:23 +0800
commit421b6efa8018de4973050e8f2799c81687395986 (patch)
treef7872b5230a3dca165445e7920ad664c4152465b /libempathy
parentb9c4083bc1c4924171bc0095d1489f6354534960 (diff)
downloadgsoc2013-empathy-421b6efa8018de4973050e8f2799c81687395986.tar
gsoc2013-empathy-421b6efa8018de4973050e8f2799c81687395986.tar.gz
gsoc2013-empathy-421b6efa8018de4973050e8f2799c81687395986.tar.bz2
gsoc2013-empathy-421b6efa8018de4973050e8f2799c81687395986.tar.lz
gsoc2013-empathy-421b6efa8018de4973050e8f2799c81687395986.tar.xz
gsoc2013-empathy-421b6efa8018de4973050e8f2799c81687395986.tar.zst
gsoc2013-empathy-421b6efa8018de4973050e8f2799c81687395986.zip
Remove the g_idle sources on destroy
Remove the GSources added with g_idle_add when destroying the EmpathyDispatcher.
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-dispatcher.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index 1dc44b309..c981eeb57 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -58,6 +58,8 @@ typedef struct
/* channels which the dispatcher is listening "invalidated" */
GList *channels;
+
+ GHashTable *request_channel_class_async_ids;
} EmpathyDispatcherPriv;
G_DEFINE_TYPE (EmpathyDispatcher, empathy_dispatcher, G_TYPE_OBJECT);
@@ -872,6 +874,17 @@ dispatcher_new_connection_cb (EmpathyAccountManager *manager,
g_ptr_array_free (capabilities, TRUE);
}
+static void
+remove_idle_handlers (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ guint source_id;
+
+ source_id = GPOINTER_TO_UINT (value);
+ g_source_remove (source_id);
+}
+
static GObject *
dispatcher_constructor (GType type,
guint n_construct_params,
@@ -904,6 +917,13 @@ dispatcher_finalize (GObject *object)
gpointer connection;
GList *list;
+ if (priv->request_channel_class_async_ids != NULL)
+ {
+ g_hash_table_foreach (priv->request_channel_class_async_ids,
+ remove_idle_handlers, NULL);
+ g_hash_table_destroy (priv->request_channel_class_async_ids);
+ }
+
g_signal_handlers_disconnect_by_func (priv->account_manager,
dispatcher_new_connection_cb, object);
@@ -1008,6 +1028,9 @@ empathy_dispatcher_init (EmpathyDispatcher *dispatcher)
g_object_unref (l->data);
}
g_list_free (connections);
+
+ priv->request_channel_class_async_ids = g_hash_table_new (g_direct_hash,
+ g_direct_equal);
}
EmpathyDispatcher *
@@ -1436,6 +1459,8 @@ find_channel_class_idle_cb (gpointer user_data)
gboolean is_ready = TRUE;
EmpathyDispatcherPriv *priv = GET_PRIV (request->dispatcher);
+ g_hash_table_remove (priv->request_channel_class_async_ids, request);
+
cd = g_hash_table_lookup (priv->connections, request->connection);
if (cd == NULL)
@@ -1472,12 +1497,16 @@ empathy_dispatcher_find_channel_class_async (EmpathyDispatcher *dispatcher,
gpointer user_data)
{
FindChannelRequest *request;
+ EmpathyDispatcherPriv *priv;
+ guint source_id;
g_return_if_fail (EMPATHY_IS_DISPATCHER (dispatcher));
g_return_if_fail (TP_IS_CONNECTION (connection));
g_return_if_fail (channel_type != NULL);
g_return_if_fail (handle_type != 0);
+ priv = GET_PRIV (dispatcher);
+
/* append another request for this connection */
request = g_slice_new0 (FindChannelRequest);
request->dispatcher = dispatcher;
@@ -1486,6 +1515,8 @@ empathy_dispatcher_find_channel_class_async (EmpathyDispatcher *dispatcher,
request->connection = connection;
request->callback = callback;
request->user_data = user_data;
+ source_id = g_idle_add (find_channel_class_idle_cb, request);
- g_idle_add (find_channel_class_idle_cb, request);
+ g_hash_table_insert (priv->request_channel_class_async_ids,
+ request, GUINT_TO_POINTER (source_id));
}