** Fix for bug #329571
authorMilan Crha <mcrha@redhat.com>
Fri, 4 Jul 2008 07:23:40 +0000 (07:23 +0000)
committerMilan Crha <mcrha@src.gnome.org>
Fri, 4 Jul 2008 07:23:40 +0000 (07:23 +0000)
2008-07-04  Milan Crha  <mcrha@redhat.com>

** Fix for bug #329571

* backends/file/e-cal-backend-file.c:
(e_cal_backend_file_modify_object):
Preserve detached instances when modifying master object.

svn path=/trunk/; revision=9094

calendar/ChangeLog
calendar/backends/file/e-cal-backend-file.c

index 9620d4d..f375c34 100644 (file)
@@ -1,3 +1,11 @@
+2008-07-04  Milan Crha  <mcrha@redhat.com>
+
+       ** Fix for bug #329571
+
+       * backends/file/e-cal-backend-file.c:
+       (e_cal_backend_file_modify_object):
+       Preserve detached instances when modifying master object.
+
 2008-06-25  Milan Crha  <mcrha@redhat.com>
 
        ** Fix for bug #476640
index 73e998e..d2b2e24 100644 (file)
@@ -1924,6 +1924,7 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, const
        ECalComponent *comp, *recurrence;
        ECalBackendFileObject *obj_data;
        struct icaltimetype current;
+       GList *detached = NULL;
 
        cbfile = E_CAL_BACKEND_FILE (backend);
        priv = cbfile->priv;
@@ -2137,10 +2138,39 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, const
                if (old_object)
                        *old_object = e_cal_component_get_as_string (obj_data->full_object);
 
+               if (obj_data->recurrences_list) {
+                       /* has detached components, preserve them */
+                       GList *l;
+
+                       for (l = obj_data->recurrences_list; l; l = l->next) {
+                               detached = g_list_prepend (detached, g_object_ref (l->data));
+                       }
+               }
+
                remove_component (cbfile, comp_uid, obj_data);
 
                /* Add the new object */
                add_component (cbfile, comp, TRUE);
+
+               if (detached) {
+                       /* it had some detached components, place them back */
+                       comp_uid = icalcomponent_get_uid (e_cal_component_get_icalcomponent (comp));
+
+                       if ((obj_data = g_hash_table_lookup (priv->comp_uid_hash, comp_uid)) != NULL) {
+                               GList *l;
+
+                               for (l = detached; l; l = l->next) {
+                                       ECalComponent *c = l->data;
+
+                                       g_hash_table_insert (obj_data->recurrences, e_cal_component_get_recurid_as_string (c), c);
+                                       icalcomponent_add_component (priv->icalcomp, e_cal_component_get_icalcomponent (c));
+                                       priv->comp = g_list_append (priv->comp, c);
+                                       obj_data->recurrences_list = g_list_append (obj_data->recurrences_list, c);
+                               }
+                       }
+
+                       g_list_free (detached);
+               }
                break;
        }