From 56d23d7d0387a57c90542eb438aa1d9f25de53b4 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Wed, 13 Sep 2000 14:26:56 +0000 Subject: Only remove the pilot item from the hash if it exists in the first place. 2000-09-13 JP Rosevear * pcs/cal-backend-file.c (remove_component): Only remove the pilot item from the hash if it exists in the first place. svn path=/trunk/; revision=5399 --- calendar/pcs/cal-backend-file.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'calendar/pcs') diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c index 078415fa02..06b75d52a6 100644 --- a/calendar/pcs/cal-backend-file.c +++ b/calendar/pcs/cal-backend-file.c @@ -473,7 +473,6 @@ add_component (CalBackendFile *cbfile, CalComponent *comp, gboolean add_to_tople CalBackendFilePrivate *priv; GList **list; const char *uid; - gchar *key; unsigned long *pilot_id; priv = cbfile->priv; @@ -501,14 +500,13 @@ add_component (CalBackendFile *cbfile, CalComponent *comp, gboolean add_to_tople */ check_dup_uid (cbfile, comp); cal_component_get_uid (comp, &uid); - key = g_strdup (uid); - g_hash_table_insert (priv->comp_uid_hash, key, comp); + g_hash_table_insert (priv->comp_uid_hash, (char *)uid, comp); /* Update the pilot list, if there is a pilot id */ cal_component_get_pilot_id (comp, &pilot_id); if (pilot_id) g_hash_table_insert (priv->comp_pilot_hash, - pilot_id, (char *)key); + pilot_id, (char *)uid); *list = g_list_prepend (*list, comp); @@ -549,9 +547,10 @@ remove_component (CalBackendFile *cbfile, CalComponent *comp) /* Remove it from our mapping */ cal_component_get_uid (comp, &uid); - cal_component_get_pilot_id (comp, &pilot_id); g_hash_table_remove (priv->comp_uid_hash, uid); - g_hash_table_remove (priv->comp_pilot_hash, pilot_id); + cal_component_get_pilot_id (comp, &pilot_id); + if (pilot_id) + g_hash_table_remove (priv->comp_pilot_hash, pilot_id); switch (cal_component_get_vtype (comp)) { case CAL_COMPONENT_EVENT: -- cgit v1.2.3