From 8157a2c4c11e6a15b52b100e5c58ba9d6cd48850 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Mon, 27 Jul 2009 17:18:41 +0200 Subject: Destroy dbus proxies in listener finalize. Makes it possible to destroy a listener and recreate one without calling the old instance callbacks (useful for unit-tests). --- libindicate/listener.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index bd3639d..5a64c81 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -277,8 +277,19 @@ indicate_listener_init (IndicateListener * listener) static void indicate_listener_finalize (GObject * obj) { - /* IndicateListener * listener = INDICATE_LISTENER(obj); */ - + IndicateListener * listener = INDICATE_LISTENER(obj); + IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener); + + if (priv->todo_idle != 0) { + g_idle_remove_by_data(obj); + } + /* Hack: proxy_struct_destroy() lacks a user_data parameter, but since the + * caller is responsible for handling params on the stack, it works + */ + g_list_foreach(priv->proxies_possible, (GFunc)proxy_struct_destroy, NULL); + g_list_free(priv->proxies_possible); + g_list_foreach(priv->proxies_working, (GFunc)proxy_struct_destroy, NULL); + g_list_free(priv->proxies_working); G_OBJECT_CLASS (indicate_listener_parent_class)->finalize (obj); return; } -- cgit v1.2.3 From 7f379d5d7fb9ddf834be4864324637b12af98750 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Mon, 27 Jul 2009 17:20:24 +0200 Subject: Removed warning: it's annoying in unittests. --- libindicate/listener.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 5a64c81..501d367 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -297,8 +297,6 @@ indicate_listener_finalize (GObject * obj) IndicateListener * indicate_listener_new (void) { - g_warning("Creating a new listener is generally discouraged, please use indicate_listener_ref_default"); - IndicateListener * listener; listener = g_object_new(INDICATE_TYPE_LISTENER, NULL); return listener; -- cgit v1.2.3