[evolution-data-server/gnome-2-32] calendar file backend: fixed incomplete sanity check in e_cal_create_object()



commit da10b0fb8ecc444c7417628d3290e827fc448edc
Author: Patrick Ohly <patrick ohly intel com>
Date:   Tue Aug 9 11:26:16 2011 +0300

    calendar file backend: fixed incomplete sanity check in e_cal_create_object()
    
    e_cal_create_object() traditionally is used for a new events which are
    unrelated to anything in the calendar. Adding detached recurrences
    to an existing meeting series has to be done with e_cal_modify_object().
    
    The code did not correctly reject the addition of a parent event for a
    previously added child event event because lookup_component() returned
    NULL in that case.
    
    This commit renames lookup_component() and redefines the return value
    to match what it is used for: checking for the existance of a UID.
    (cherry picked from commit 0c178bbab1008a8574d58c2019c22f892010d9a0)

 calendar/backends/file/e-cal-backend-file.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index 1c2bda6..49fe344 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -389,9 +389,11 @@ e_cal_backend_file_finalize (GObject *object)
 
 
 
-/* Looks up a component by its UID on the backend's component hash table */
-static ECalComponent *
-lookup_component (ECalBackendFile *cbfile, const gchar *uid)
+/* Looks up an component by its UID on the backend's component hash table
+   and returns TRUE if any event (regardless whether it is the master or a child)
+   with that UID exists */
+static gboolean
+uid_in_use (ECalBackendFile *cbfile, const gchar *uid)
 {
 	ECalBackendFilePrivate *priv;
 	ECalBackendFileObject *obj_data;
@@ -399,7 +401,7 @@ lookup_component (ECalBackendFile *cbfile, const gchar *uid)
 	priv = cbfile->priv;
 
 	obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid);
-	return obj_data ? obj_data->full_object : NULL;
+	return obj_data != NULL;
 }
 
 
@@ -2333,7 +2335,7 @@ e_cal_backend_file_create_object (ECalBackendSync *backend, EDataCal *cal, gchar
 	}
 
 	/* check the object is not in our cache */
-	if (lookup_component (cbfile, comp_uid)) {
+	if (uid_in_use (cbfile, comp_uid)) {
 		icalcomponent_free (icalcomp);
 		g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
 		g_propagate_error (error, EDC_ERROR (ObjectIdAlreadyExists));



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