** Fix for bug #475781
authorMilan Crha <mcrha@redhat.com>
Fri, 25 Jan 2008 13:42:58 +0000 (13:42 +0000)
committerMilan Crha <mcrha@src.gnome.org>
Fri, 25 Jan 2008 13:42:58 +0000 (13:42 +0000)
2008-01-25  Milan Crha  <mcrha@redhat.com>

** Fix for bug #475781

* libecal/e-cal-component.c: (e_cal_component_free_datetime):
* backends/groupwise/e-cal-backend-groupwise-utils.c:
(set_properties_from_cal_component), (e_gw_item_to_cal_component):
* libecal/e-cal.c: (add_instance):
Fix memory leaks around ECalComponentDateTime.

svn path=/trunk/; revision=8423

calendar/ChangeLog
calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
calendar/libecal/e-cal-component.c
calendar/libecal/e-cal.c

index 5ec46c1..db90134 100644 (file)
@@ -1,5 +1,15 @@
 2008-01-25  Milan Crha  <mcrha@redhat.com>
 
+       ** Fix for bug #475781
+
+       * libecal/e-cal-component.c: (e_cal_component_free_datetime):
+       * backends/groupwise/e-cal-backend-groupwise-utils.c:
+       (set_properties_from_cal_component), (e_gw_item_to_cal_component):
+       * libecal/e-cal.c: (add_instance):
+       Fix memory leaks around ECalComponentDateTime.
+
+2008-01-25  Milan Crha  <mcrha@redhat.com>
+
        ** Fix for bug #510409
 
        * backends/groupwise/e-cal-backend-groupwise.c: (get_deltas),
index 2f8f908..f699b3c 100644 (file)
@@ -533,6 +533,7 @@ set_properties_from_cal_component (EGwItem *item, ECalComponent *comp, ECalBacke
        GSList *slist, *sl;
        icaltimezone *default_zone, *utc;
        struct icaltimetype itt_utc;
+       gboolean dtstart_has_timezone;
 
        default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
        utc = icaltimezone_get_utc_timezone ();
@@ -580,6 +581,7 @@ set_properties_from_cal_component (EGwItem *item, ECalComponent *comp, ECalBacke
                                icaltime_set_timezone (dt.value, default_zone ? default_zone : utc);
                        itt_utc = icaltime_convert_to_zone (*dt.value, utc);
                        e_gw_item_set_end_date (item, icaltime_as_ical_string (itt_utc));
+                       e_cal_component_free_datetime (&dt);
                }
 
                break;
@@ -594,28 +596,31 @@ set_properties_from_cal_component (EGwItem *item, ECalComponent *comp, ECalBacke
                                icaltime_set_timezone (dt.value, default_zone);
                        itt_utc = icaltime_convert_to_zone (*dt.value, utc);
                        e_gw_item_set_due_date (item, icaltime_as_ical_string (itt_utc));
+                       e_cal_component_free_datetime (&dt);
                }
 
-                       /* priority */
-                priority = NULL;
-                e_cal_component_get_priority (comp, &priority);
-                if (priority && *priority) {
-                        if (*priority >= 7)
-                                e_gw_item_set_task_priority (item, E_GW_ITEM_PRIORITY_LOW);
-                        else if (*priority >= 5)
-                                e_gw_item_set_task_priority (item, E_GW_ITEM_PRIORITY_STANDARD);
-                        else if (*priority >= 1)
-                                e_gw_item_set_task_priority (item, E_GW_ITEM_PRIORITY_HIGH);
-                        else
-                                e_gw_item_set_task_priority (item, NULL);
-
-                        e_cal_component_free_priority (priority);
-                }
-
-                       /* completed */
+               /* priority */
+               priority = NULL;
+               e_cal_component_get_priority (comp, &priority);
+               if (priority && *priority) {
+                       if (*priority >= 7)
+                               e_gw_item_set_task_priority (item, E_GW_ITEM_PRIORITY_LOW);
+                       else if (*priority >= 5)
+                               e_gw_item_set_task_priority (item, E_GW_ITEM_PRIORITY_STANDARD);
+                       else if (*priority >= 1)
+                               e_gw_item_set_task_priority (item, E_GW_ITEM_PRIORITY_HIGH);
+                       else
+                               e_gw_item_set_task_priority (item, NULL);
+
+                       e_cal_component_free_priority (priority);
+               }
+
+               /* completed */
                e_cal_component_get_completed (comp, &dt.value);
                if (dt.value) {
                        e_gw_item_set_completed (item, TRUE);
+                       e_cal_component_free_icaltimetype (dt.value);
+                       dt.value = NULL;
                } else
                        e_gw_item_set_completed (item, FALSE);
 
@@ -668,6 +673,7 @@ set_properties_from_cal_component (EGwItem *item, ECalComponent *comp, ECalBacke
                itt_utc = icaltime_convert_to_zone (*dt.value, utc);
                e_gw_item_set_start_date (item, icaltime_as_ical_string (itt_utc));
        } else if (e_gw_item_get_item_type (item) == E_GW_ITEM_TYPE_APPOINTMENT) {
+               e_cal_component_free_datetime (&dt);
                /* appointments need the start date property */
                g_object_unref (item);
                return NULL;
@@ -677,6 +683,9 @@ set_properties_from_cal_component (EGwItem *item, ECalComponent *comp, ECalBacke
        if (dt.value && dt.value->is_date && e_gw_item_get_item_type (item) == E_GW_ITEM_TYPE_APPOINTMENT)
                e_gw_item_set_is_allday_event (item, TRUE);
 
+       dtstart_has_timezone = dt.tzid != NULL;
+       e_cal_component_free_datetime (&dt);
+
        /* creation date */
        e_cal_component_get_created (comp, &dt.value);
        if (dt.value) {
@@ -691,6 +700,9 @@ set_properties_from_cal_component (EGwItem *item, ECalComponent *comp, ECalBacke
                e_gw_item_set_creation_date (item, icaltime_as_ical_string (itt));
        }
 
+       e_cal_component_free_icaltimetype (dt.value);
+       dt.value = NULL;
+
        /* classification */
        e_cal_component_get_classification (comp, &classif);
        switch (classif) {
@@ -718,7 +730,7 @@ set_properties_from_cal_component (EGwItem *item, ECalComponent *comp, ECalBacke
 
                        GSList *recur_dates = NULL;
 
-                       if (dt.tzid)
+                       if (dtstart_has_timezone)
                                e_cal_recur_generate_instances (comp, -1, -1,get_recur_instance, &recur_dates, resolve_tzid_cb, NULL, (icaltimezone *) default_zone);
                        else
                                e_cal_recur_generate_instances (comp, -1, -1,get_recur_instance, &recur_dates, resolve_tzid_cb, NULL, utc);
@@ -1087,6 +1099,7 @@ e_gw_item_to_cal_component (EGwItem *item, ECalBackendGroupwise *cbgw)
                recur_id->type = E_CAL_COMPONENT_RANGE_SINGLE;
                recur_id->datetime = dt;
                e_cal_component_set_recurid (comp, recur_id);
+               g_free (recur_id);
        } else {
 
                uid = e_gw_item_get_icalid (item);
index 92bd4b3..f61798b 100644 (file)
@@ -4736,6 +4736,9 @@ e_cal_component_free_datetime (ECalComponentDateTime *dt)
 
        g_free (dt->value);
        g_free ((char*)dt->tzid);
+
+       dt->value = NULL;
+       dt->tzid = NULL;
 }
 
 /**
index f0b4052..d8fd97f 100644 (file)
@@ -3330,7 +3330,6 @@ add_instance (ECalComponent *comp, time_t start, time_t end, gpointer data)
        struct icaltimetype itt;
        icalcomponent *icalcomp;
        struct instances_info *instances_hold;
-       ECalComponentDateTime datetime;
 
        instances_hold = data;
        list = instances_hold->instances;
@@ -3338,7 +3337,6 @@ add_instance (ECalComponent *comp, time_t start, time_t end, gpointer data)
        ci = g_new (struct comp_instance, 1);
 
        icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp));
-       e_cal_component_get_dtstart (comp, &datetime);
 
        /* add the instance to the list */
        ci->comp = e_cal_component_new ();
@@ -3348,6 +3346,9 @@ add_instance (ECalComponent *comp, time_t start, time_t end, gpointer data)
        if (e_cal_util_component_has_recurrences (icalcomp)) {
                if (!(icalcomponent_get_first_property (icalcomp, ICAL_RECURRENCEID_PROPERTY))) {
                        ECalComponentRange *range;
+                       ECalComponentDateTime datetime;
+
+                       e_cal_component_get_dtstart (comp, &datetime);
 
                        if (instances_hold->start_zone)
                                itt = icaltime_from_timet_with_zone (start, datetime.value->is_date, instances_hold->start_zone);