Re: [evolution-patches] [calendar] patch for #60310



On Sat, 2004-07-24 at 10:30 -0400, JP Rosevear wrote:
> On Sat, 2004-07-24 at 11:51 +0200, Rodrigo Moya wrote:
> > On Fri, 2004-07-23 at 15:44 -0400, JP Rosevear wrote:
> > > Why would the key be NULL in match_recurrence_sexp?
> > > 
> > not sure, since we can't add items to the hash table with a NULL key, or
> > can we? In any case, that's what seems to be the case.
> 
> Sounds like we are deleting items from the hash while in a foreach call
> or something similar.
> 
right, the attached patch might probably fix it. Can't confirm though
since I haven't been able to replicate the bug at all)
-- 
Rodrigo Moya <rodrigo novell com>
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.306
diff -u -p -r1.306 ChangeLog
--- ChangeLog	4 Aug 2004 05:38:29 -0000	1.306
+++ ChangeLog	6 Aug 2004 15:15:31 -0000
@@ -1,3 +1,12 @@
+2004-08-06  Rodrigo Moya <rodrigo novell com>
+
+	Probably fixes #60310
+
+	* backends/file/e-cal-backend-file.c (remove_recurrence_cb,
+	remove_component): use g_hash_table_foreach_remove instead
+	of simple foreach so that we remove the hash items as we
+	free them.
+
 2004-08-04  Chenthill Palanisamy <pchenthill novell com>
 
        Fixes #60265
Index: backends/file/e-cal-backend-file.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/file/e-cal-backend-file.c,v
retrieving revision 1.34
diff -u -p -r1.34 e-cal-backend-file.c
--- backends/file/e-cal-backend-file.c	11 Jun 2004 15:54:15 -0000	1.34
+++ backends/file/e-cal-backend-file.c	6 Aug 2004 15:15:32 -0000
@@ -465,7 +465,7 @@ add_component (ECalBackendFile *cbfile, 
 }
 
 /* g_hash_table_foreach() callback to remove recurrences from the calendar */
-static void
+static gboolean
 remove_recurrence_cb (gpointer key, gpointer value, gpointer data)
 {
 	GList *l;
@@ -491,6 +491,12 @@ remove_recurrence_cb (gpointer key, gpoi
 	e_cal_component_get_categories_list (comp, &categories);
 	e_cal_backend_unref_categories (E_CAL_BACKEND (cbfile), categories);
 	e_cal_component_free_categories_list (categories);
+
+	/* free memory */
+	g_free (key);
+	g_object_unref (comp);
+
+	return TRUE;
 }
 
 /* Removes a component from the backend's hash and lists.  Does not perform
@@ -530,7 +536,7 @@ remove_component (ECalBackendFile *cbfil
 	priv->comp = g_list_delete_link (priv->comp, l);
 
 	/* remove the recurrences also */
-	g_hash_table_foreach (obj_data->recurrences, (GHFunc) remove_recurrence_cb, cbfile);
+	g_hash_table_foreach_remove (obj_data->recurrences, (GHRFunc) remove_recurrence_cb, cbfile);
 
 	/* Update the set of categories */
 	e_cal_component_get_categories_list (comp, &categories);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]