From aa2582564da8733bea469e473c24e5ee10c3874f Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Tue, 6 Jan 2009 16:48:19 +0000 Subject: Drop our references in dispose instead of finalize. svn path=/trunk/; revision=2069 --- libempathy/empathy-contact-monitor.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-contact-monitor.c b/libempathy/empathy-contact-monitor.c index e48f08655..b024e1b86 100644 --- a/libempathy/empathy-contact-monitor.c +++ b/libempathy/empathy-contact-monitor.c @@ -35,6 +35,8 @@ typedef struct { EmpathyContactList *proxy; GPtrArray *contacts; + + gboolean dispose_run; } EmpathyContactMonitorPriv; enum { @@ -111,8 +113,6 @@ do_finalize (GObject *obj) priv = GET_PRIV (obj); if (priv->contacts) { - g_ptr_array_foreach (priv->contacts, - (GFunc) contact_remove_foreach, obj); g_ptr_array_free (priv->contacts, TRUE); priv->contacts = NULL; } @@ -125,12 +125,39 @@ do_finalize (GObject *obj) G_OBJECT_CLASS (empathy_contact_monitor_parent_class)->finalize (obj); } +static void +do_dispose (GObject *obj) +{ + EmpathyContactMonitorPriv *priv; + + priv = GET_PRIV (obj); + + if (priv->dispose_run) { + return; + } + + if (priv->contacts) { + g_ptr_array_foreach (priv->contacts, + (GFunc) contact_remove_foreach, obj); + } + + if (priv->proxy) { + g_signal_handlers_disconnect_by_func (priv->proxy, + cl_members_changed_cb, obj); + } + + priv->dispose_run = TRUE; + + G_OBJECT_CLASS (empathy_contact_monitor_parent_class)->dispose (obj); +} + static void empathy_contact_monitor_class_init (EmpathyContactMonitorClass *klass) { GObjectClass *oclass = G_OBJECT_CLASS (klass); oclass->finalize = do_finalize; + oclass->dispose = do_dispose; oclass->get_property = do_get_property; oclass->set_property = do_set_property; @@ -225,6 +252,7 @@ empathy_contact_monitor_init (EmpathyContactMonitor *self) self->priv = priv; priv->contacts = NULL; priv->proxy = NULL; + priv->dispose_run = FALSE; } static void -- cgit v1.2.3