evolution-data-server r8423 - in trunk/calendar: . backends/groupwise libecal



Author: mcrha
Date: Fri Jan 25 13:42:58 2008
New Revision: 8423
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8423&view=rev

Log:
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.



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

Modified: trunk/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
==============================================================================
--- trunk/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	(original)
+++ trunk/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	Fri Jan 25 13:42:58 2008
@@ -533,6 +533,7 @@
 	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 @@
 				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 @@
 				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);
+		/* 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);
-		 }
+			e_cal_component_free_priority (priority);
+		}
 
-			/* completed */
+		/* 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 @@
 		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 @@
 	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 @@
 		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 @@
 
 			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 @@
 		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);

Modified: trunk/calendar/libecal/e-cal-component.c
==============================================================================
--- trunk/calendar/libecal/e-cal-component.c	(original)
+++ trunk/calendar/libecal/e-cal-component.c	Fri Jan 25 13:42:58 2008
@@ -4736,6 +4736,9 @@
 
 	g_free (dt->value);
 	g_free ((char*)dt->tzid);
+
+	dt->value = NULL;
+	dt->tzid = NULL;
 }
 
 /**

Modified: trunk/calendar/libecal/e-cal.c
==============================================================================
--- trunk/calendar/libecal/e-cal.c	(original)
+++ trunk/calendar/libecal/e-cal.c	Fri Jan 25 13:42:58 2008
@@ -3330,7 +3330,6 @@
 	struct icaltimetype itt;
 	icalcomponent *icalcomp;
 	struct instances_info *instances_hold;
-	ECalComponentDateTime datetime;
 
 	instances_hold = data;
 	list = instances_hold->instances;
@@ -3338,7 +3337,6 @@
 	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 @@
 	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);



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