From 29c2c9098e10451d6339748dbfc58c5b5fb68d28 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 20 May 2003 12:00:38 +0000 Subject: Don't double-free newly-added categories that the gui hasn't been told * pcs/cal-backend.c (cal_backend_finalize): Don't double-free newly-added categories that the gui hasn't been told about yet. #43321 svn path=/trunk/; revision=21275 --- calendar/pcs/cal-backend.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'calendar/pcs') diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c index bf974ddc70..f493302136 100644 --- a/calendar/pcs/cal-backend.c +++ b/calendar/pcs/cal-backend.c @@ -222,6 +222,16 @@ free_category_cb (gpointer key, gpointer value, gpointer data) g_free (c); } +static gboolean +prune_changed_categories (gpointer key, gpointer value, gpointer data) +{ + CalBackendCategory *c = value; + + if (!c->refcount) + free_category_cb (key, value, data); + return TRUE; +} + void cal_backend_finalize (GObject *object) { @@ -232,12 +242,12 @@ cal_backend_finalize (GObject *object) g_assert (priv->clients == NULL); + g_hash_table_foreach_remove (priv->changed_categories, prune_changed_categories, NULL); + g_hash_table_destroy (priv->changed_categories); + g_hash_table_foreach (priv->categories, free_category_cb, NULL); g_hash_table_destroy (priv->categories); - g_hash_table_foreach (priv->changed_categories, free_category_cb, NULL); - g_hash_table_destroy (priv->changed_categories); - if (priv->category_idle_id) g_source_remove (priv->category_idle_id); @@ -1152,18 +1162,6 @@ notify_categories_changed (CalBackend *backend) CORBA_free (seq); } -static gboolean -prune_changed_categories (gpointer key, gpointer value, gpointer data) -{ - CalBackendCategory *category = value; - - if (!category->refcount) { - g_free (category->name); - g_free (category); - } - return TRUE; -} - static gboolean idle_notify_categories_changed (gpointer data) { -- cgit