summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2011-08-09 11:26:16 +0300
committerPatrick Ohly <patrick.ohly@intel.com>2011-08-10 18:09:40 +0200
commitddc2261568c4a4a6d5a39adabaa3bc190b380991 (patch)
tree6b073d1c42029db73e3141b50e388d735285794e
parent6c118d9e5057124e34739b67db177e80c7d6e0f3 (diff)
downloadevolution-data-server-ddc2261568c4a4a6d5a39adabaa3bc190b380991.tar.gz
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)
-rw-r--r--calendar/backends/file/e-cal-backend-file.c12
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 c0bc2876b..eddb28e41 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;
}
@@ -2327,7 +2329,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));