evolution r34895 - in trunk: calendar calendar/gui calendar/gui/dialogs plugins/itip-formatter plugins/save-calendar



Author: mcrha
Date: Fri Jan 25 14:10:07 2008
New Revision: 34895
URL: http://svn.gnome.org/viewvc/evolution?rev=34895&view=rev

Log:
2008-01-25  Milan Crha  <mcrha redhat com>

	** Fix for bug #475781

	* plugins/save-calendar/csv-format.c: (do_save_calendar_csv):
	* plugins/save-calendar/rdf-format.c: (do_save_calendar_rdf):
	* plugins/itip-formatter/itip-formatter.c: (format_itip_object):
	* calendar/gui/dialogs/recurrence-page.c: (fill_ending_date),
	(recurrence_page_fill_widgets):
	* calendar/gui/dialogs/memo-page.c: (memo_page_fill_widgets):
	* calendar/gui/e-day-view.c: 2*(e_day_view_finish_long_event_resize),
	2*(e_day_view_on_editing_stopped):
	* calendar/gui/itip-utils.c: (comp_compliant), (reply_to_calendar_comp):
	* calendar/gui/e-week-view.c: (e_week_view_on_editing_stopped):
	* calendar/gui/e-calendar-view.c: (e_calendar_view_add_event),
	(e_calendar_view_get_tooltips):
	* calendar/gui/e-cal-component-preview.c: (write_html):
	* calendar/gui/e-cal-component-memo-preview.c: (write_html):
	* calendar/gui/e-cal-model.c: (add_instance_cb):
	Fix memory leaks around ECalComponentDateTime.



Modified:
   trunk/calendar/ChangeLog
   trunk/calendar/gui/dialogs/memo-page.c
   trunk/calendar/gui/dialogs/recurrence-page.c
   trunk/calendar/gui/e-cal-component-memo-preview.c
   trunk/calendar/gui/e-cal-component-preview.c
   trunk/calendar/gui/e-cal-model.c
   trunk/calendar/gui/e-calendar-view.c
   trunk/calendar/gui/e-day-view.c
   trunk/calendar/gui/e-week-view.c
   trunk/calendar/gui/itip-utils.c
   trunk/plugins/itip-formatter/ChangeLog
   trunk/plugins/itip-formatter/itip-formatter.c
   trunk/plugins/save-calendar/ChangeLog
   trunk/plugins/save-calendar/csv-format.c
   trunk/plugins/save-calendar/rdf-format.c

Modified: trunk/calendar/gui/dialogs/memo-page.c
==============================================================================
--- trunk/calendar/gui/dialogs/memo-page.c	(original)
+++ trunk/calendar/gui/dialogs/memo-page.c	Fri Jan 25 14:10:07 2008
@@ -413,6 +413,7 @@
 				      start_tt->day);
 	} else if (!(page->flags & COMP_EDITOR_PAGE_NEW_ITEM))
 		e_date_edit_set_time (E_DATE_EDIT (priv->start_date), -1);
+	e_cal_component_free_datetime (&d);
 
 	/* Classification. */
 	e_cal_component_get_classification (comp, &cl);

Modified: trunk/calendar/gui/dialogs/recurrence-page.c
==============================================================================
--- trunk/calendar/gui/dialogs/recurrence-page.c	(original)
+++ trunk/calendar/gui/dialogs/recurrence-page.c	Fri Jan 25 14:10:07 2008
@@ -1528,6 +1528,8 @@
 				r->until.second = 0;
 				r->until.is_date = TRUE;
 				r->until.is_utc = FALSE;
+
+				e_cal_component_free_datetime (&dt);
 			}
 
 			priv->ending_date_tt = r->until;
@@ -1774,6 +1776,7 @@
 				e_cal_component_get_dtstart (comp, &dt);
 				priv->month_index = dt.value->day;
 				priv->month_num = MONTH_NUM_LAST;
+				e_cal_component_free_datetime (&dt);
 			} else {
 				priv->month_index = nth;
 				priv->month_num = MONTH_NUM_DAY;

Modified: trunk/calendar/gui/e-cal-component-memo-preview.c
==============================================================================
--- trunk/calendar/gui/e-cal-component-memo-preview.c	(original)
+++ trunk/calendar/gui/e-cal-component-memo-preview.c	Fri Jan 25 14:10:07 2008
@@ -211,9 +211,9 @@
 		gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD><TD>%s</TD></TR>",
 					_("Start Date:"), str);
 
-		e_cal_component_free_datetime (&dt);
 		g_free (str);
 	}
+	e_cal_component_free_datetime (&dt);
 
 	/* write description and URL */
 	gtk_html_stream_printf (stream, "<TR><TD COLSPAN=\"2\"><HR></TD></TR>");

Modified: trunk/calendar/gui/e-cal-component-preview.c
==============================================================================
--- trunk/calendar/gui/e-cal-component-preview.c	(original)
+++ trunk/calendar/gui/e-cal-component-preview.c	Fri Jan 25 14:10:07 2008
@@ -199,9 +199,9 @@
 		gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD><TD>%s</TD></TR>",
 					_("Start Date:"), str);
 
-		e_cal_component_free_datetime (&dt);
 		g_free (str);
 	}
+	e_cal_component_free_datetime (&dt);
 
 	/* write end date */
 	e_cal_component_get_dtend (comp, &dt);
@@ -210,9 +210,9 @@
 		gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD><TD>%s</TD></TR>",
 					_("Start Date:"), str);
 
-		e_cal_component_free_datetime (&dt);
 		g_free (str);
 	}
+	e_cal_component_free_datetime (&dt);
 
 	/* write Due Date */
 	e_cal_component_get_due (comp, &dt);
@@ -221,9 +221,9 @@
 		gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD><TD>%s</TD></TR>",
 					_("Due Date:"), str);
 
-		e_cal_component_free_datetime (&dt);
 		g_free (str);
 	}
+	e_cal_component_free_datetime (&dt);
 
 	/* write status */
 	gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Status:"));

Modified: trunk/calendar/gui/e-cal-model.c
==============================================================================
--- trunk/calendar/gui/e-cal-model.c	(original)
+++ trunk/calendar/gui/e-cal-model.c	Fri Jan 25 14:10:07 2008
@@ -1347,6 +1347,7 @@
 	to_set.value = &time;
 	to_set.tzid = datetime.tzid;
 	e_cal_component_set_dtstart (comp, &to_set);
+	e_cal_component_free_datetime (&datetime);
 
 	/* set the right instance end date to component*/
 	e_cal_component_get_dtend (comp, &datetime);
@@ -1355,6 +1356,7 @@
 	to_set.value = &time;
 	to_set.tzid = datetime.tzid;
 	e_cal_component_set_dtend (comp, &to_set);
+	e_cal_component_free_datetime (&datetime);
 
 	comp_data = g_new0 (ECalModelComponent, 1);
 	comp_data->client = g_object_ref (rdata->client);

Modified: trunk/calendar/gui/e-calendar-view.c
==============================================================================
--- trunk/calendar/gui/e-calendar-view.c	(original)
+++ trunk/calendar/gui/e-calendar-view.c	Fri Jan 25 14:10:07 2008
@@ -363,13 +363,16 @@
 	g_free (uid);
 
 	/* set the timezone properly */
-	dt.value = &itime;
 	e_cal_component_get_dtstart (comp, &dt);
 	dt.tzid = icaltimezone_get_tzid (default_zone);
 	e_cal_component_set_dtstart (comp, &dt);
+	e_cal_component_free_datetime (&dt);
+
 	e_cal_component_get_dtend (comp, &dt);
 	dt.tzid = icaltimezone_get_tzid (default_zone);
 	e_cal_component_set_dtend (comp, &dt);
+	e_cal_component_free_datetime (&dt);
+
 	e_cal_component_commit_sequence (comp);
 
 	/* FIXME Error handling */
@@ -2246,6 +2249,9 @@
 	tmp1 = get_label(dtstart.value, zone, default_zone);
 	tmp = calculate_time (t_start, t_end);
 
+	e_cal_component_free_datetime (&dtstart);
+	e_cal_component_free_datetime (&dtend);
+
 	/* To Translators: It will display "Time: ActualStartDateAndTime (DurationOfTheMeeting)"*/
 	tmp2 = g_strdup_printf(_("Time: %s %s"), tmp1, tmp);
 	hbox = gtk_hbox_new (FALSE, 0);

Modified: trunk/calendar/gui/e-day-view.c
==============================================================================
--- trunk/calendar/gui/e-day-view.c	(original)
+++ trunk/calendar/gui/e-day-view.c	Fri Jan 25 14:10:07 2008
@@ -4969,23 +4969,31 @@
 	date.tzid = NULL;
 
 	if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_LEFT_EDGE) {
-		e_cal_component_get_dtstart (comp, &date);
-		is_date = date.value->is_date;
+		ECalComponentDateTime ecdt;
+
+		e_cal_component_get_dtstart (comp, &ecdt);
+		is_date = ecdt.value && ecdt.value->is_date;
 		if (!is_date)
 			date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
 		dt = day_view->day_starts[day_view->resize_start_row];
 		*date.value = icaltime_from_timet_with_zone (dt, is_date,
 							     e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
 		e_cal_component_set_dtstart (comp, &date);
+		e_cal_component_free_datetime (&ecdt);
+		date.tzid = NULL; /* do not reuse it later */
 	} else {
-		e_cal_component_get_dtend (comp, &date);
-		is_date = date.value->is_date;
+		ECalComponentDateTime ecdt;
+
+		e_cal_component_get_dtend (comp, &ecdt);
+		is_date = ecdt.value && ecdt.value->is_date;
 		if (!is_date)
 			date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
 		dt = day_view->day_starts[day_view->resize_end_row + 1];
 		*date.value = icaltime_from_timet_with_zone (dt, is_date,
 							     e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
 		e_cal_component_set_dtend (comp, &date);
+		e_cal_component_free_datetime (&ecdt);
+		date.tzid = NULL; /* do not reuse it later */
 	}
 
 	e_cal_component_commit_sequence (comp);
@@ -5209,23 +5217,31 @@
 	date.tzid = NULL;
 
 	if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_LEFT_EDGE) {
-		e_cal_component_get_dtstart (comp, &date);
-		is_date = date.value->is_date;
+		ECalComponentDateTime ecdt;
+
+		e_cal_component_get_dtstart (comp, &ecdt);
+		is_date = ecdt.value && ecdt.value->is_date;
 		if (!is_date)
 			date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
 		dt = day_view->day_starts[day_view->resize_start_row];
 		*date.value = icaltime_from_timet_with_zone (dt, is_date,
 							     e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
 		e_cal_component_set_dtstart (comp, &date);
+		e_cal_component_free_datetime (&ecdt);
+		date.tzid = NULL; /* do not reuse it later */
 	} else {
+		ECalComponentDateTime ecdt;
+
 		e_cal_component_get_dtend (comp, &date);
-		is_date = date.value->is_date;
+		is_date = ecdt.value && ecdt.value->is_date;
 		if (!is_date)
 			date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
 		dt = day_view->day_starts[day_view->resize_end_row + 1];
 		*date.value = icaltime_from_timet_with_zone (dt, is_date,
 							     e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
 		e_cal_component_set_dtend (comp, &date);
+		e_cal_component_free_datetime (&ecdt);
+		date.tzid = NULL; /* do not reuse it later */
 	}
 
 	e_cal_component_commit_sequence (comp);
@@ -7733,35 +7749,41 @@
 				}
 
 				if (mod == CALOBJ_MOD_THIS) {
-					ECalComponentDateTime dt;
+					ECalComponentDateTime olddt, dt;
 
-					e_cal_component_get_dtstart (comp, &dt);
-					if (dt.value->zone) {
+					e_cal_component_get_dtstart (comp, &olddt);
+					if (olddt.value->zone) {
 						*dt.value = icaltime_from_timet_with_zone (
 							event->comp_data->instance_start,
-							dt.value->is_date,
-							dt.value->zone);
+							olddt.value->is_date,
+							olddt.value->zone);
 					} else {
 						*dt.value = icaltime_from_timet_with_zone (
 							event->comp_data->instance_start,
-							dt.value->is_date,
+							olddt.value->is_date,
 							e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
 					}
+					dt.tzid = olddt.tzid;
 					e_cal_component_set_dtstart (comp, &dt);
+					dt.tzid = NULL;
+					e_cal_component_free_datetime (&olddt);
 
-					e_cal_component_get_dtend (comp, &dt);
-					if (dt.value->zone) {
+					e_cal_component_get_dtend (comp, &olddt);
+					if (olddt.value->zone) {
 						*dt.value = icaltime_from_timet_with_zone (
 							event->comp_data->instance_end,
-							dt.value->is_date,
-							dt.value->zone);
+							olddt.value->is_date,
+							olddt.value->zone);
 					} else {
 						*dt.value = icaltime_from_timet_with_zone (
 							event->comp_data->instance_end,
-							dt.value->is_date,
+							olddt.value->is_date,
 							e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
 					}
+					dt.tzid = olddt.tzid;
 					e_cal_component_set_dtend (comp, &dt);
+					dt.tzid = NULL;
+					e_cal_component_free_datetime (&olddt);
 
 					e_cal_component_set_rdate_list (comp, NULL);
 					e_cal_component_set_rrule_list (comp, NULL);
@@ -7890,35 +7912,41 @@
 				}
 
 				if (mod == CALOBJ_MOD_THIS) {
-					ECalComponentDateTime dt;
+					ECalComponentDateTime olddt, dt;
 
-					e_cal_component_get_dtstart (comp, &dt);
-					if (dt.value->zone) {
+					e_cal_component_get_dtstart (comp, &olddt);
+					if (olddt.value->zone) {
 						*dt.value = icaltime_from_timet_with_zone (
 							event->comp_data->instance_start,
-							dt.value->is_date,
-							dt.value->zone);
+							olddt.value->is_date,
+							olddt.value->zone);
 					} else {
 						*dt.value = icaltime_from_timet_with_zone (
 							event->comp_data->instance_start,
-							dt.value->is_date,
+							olddt.value->is_date,
 							e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
 					}
+					dt.tzid = olddt.tzid;
 					e_cal_component_set_dtstart (comp, &dt);
+					dt.tzid = NULL;
+					e_cal_component_free_datetime (&olddt);
 
-					e_cal_component_get_dtend (comp, &dt);
-					if (dt.value->zone) {
+					e_cal_component_get_dtend (comp, &olddt);
+					if (olddt.value->zone) {
 						*dt.value = icaltime_from_timet_with_zone (
 							event->comp_data->instance_end,
-							dt.value->is_date,
-							dt.value->zone);
+							olddt.value->is_date,
+							olddt.value->zone);
 					} else {
 						*dt.value = icaltime_from_timet_with_zone (
 							event->comp_data->instance_end,
-							dt.value->is_date,
+							olddt.value->is_date,
 							e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
 					}
+					dt.tzid = olddt.tzid;
 					e_cal_component_set_dtend (comp, &dt);
+					dt.tzid = NULL;
+					e_cal_component_free_datetime (&olddt);
 
 					e_cal_component_set_rdate_list (comp, NULL);
 					e_cal_component_set_rrule_list (comp, NULL);

Modified: trunk/calendar/gui/e-week-view.c
==============================================================================
--- trunk/calendar/gui/e-week-view.c	(original)
+++ trunk/calendar/gui/e-week-view.c	Fri Jan 25 14:10:07 2008
@@ -3532,20 +3532,27 @@
 
 				if (mod == CALOBJ_MOD_THIS) {
 					ECalComponentDateTime dt;
+					struct icaltimetype tt;
+					char *tzid;
 
 					e_cal_component_get_dtstart (comp, &dt);
 					if (dt.value->zone) {
-						*dt.value = icaltime_from_timet_with_zone (
+						tt = icaltime_from_timet_with_zone (
 							event->comp_data->instance_start,
 							dt.value->is_date,
 							dt.value->zone);
 					} else {
-						*dt.value = icaltime_from_timet_with_zone (
+						tt = icaltime_from_timet_with_zone (
 							event->comp_data->instance_start,
 							dt.value->is_date,
 							e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view)));
 					}
+					tzid = g_strdup (dt.tzid);
+					e_cal_component_free_datetime (&dt);
+					dt.value = &tt;
+					dt.tzid = tzid;
 					e_cal_component_set_dtstart (comp, &dt);
+					g_free (tzid);
 
 					e_cal_component_get_dtend (comp, &dt);
 					if (dt.value->zone) {
@@ -3559,7 +3566,12 @@
 							dt.value->is_date,
 							e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view)));
 					}
+					tzid = g_strdup (dt.tzid);
+					e_cal_component_free_datetime (&dt);
+					dt.value = &tt;
+					dt.tzid = tzid;
 					e_cal_component_set_dtend (comp, &dt);
+					g_free (tzid);
 
 					e_cal_component_set_rdate_list (comp, NULL);
 					e_cal_component_set_rrule_list (comp, NULL);

Modified: trunk/calendar/gui/itip-utils.c
==============================================================================
--- trunk/calendar/gui/itip-utils.c	(original)
+++ trunk/calendar/gui/itip-utils.c	Fri Jan 25 14:10:07 2008
@@ -1109,6 +1109,7 @@
 			icaltimezone_convert_time (&r->until, from_zone, to_zone);
 			r->until.is_utc = TRUE;
 
+			e_cal_component_free_datetime (&dt);
 			e_cal_component_set_rrule_list (clone, rrule_list);
 			e_cal_component_abort_sequence (clone);
 		}
@@ -1515,6 +1516,7 @@
 			time = g_strdup (ctime (&start));
 		}
 
+		e_cal_component_free_datetime (&dtstart);
 
 		body = g_string_new ("<br><br><hr><br><b>______ Original Appointment ______ </b><br><br><table>");
 

Modified: trunk/plugins/itip-formatter/itip-formatter.c
==============================================================================
--- trunk/plugins/itip-formatter/itip-formatter.c	(original)
+++ trunk/plugins/itip-formatter/itip-formatter.c	Fri Jan 25 14:10:07 2008
@@ -2082,16 +2082,16 @@
 	/* Set the recurrence id */
 	if (check_is_instance (icalcomp) && datetime.value) {
 		ECalComponentRange *recur_id;
-
-		*datetime.value = icaltime_convert_to_zone (*datetime.value, to_zone);
-		datetime.tzid = icaltimezone_get_tzid (to_zone);
+		struct icaltimetype icaltime = icaltime_convert_to_zone (*datetime.value, to_zone);
 
 		recur_id = g_new0 (ECalComponentRange, 1);
 		recur_id->type = E_CAL_COMPONENT_RANGE_SINGLE;
-		recur_id->datetime = datetime;
+		recur_id->datetime.value = &icaltime;
+		recur_id->datetime.tzid = icaltimezone_get_tzid (to_zone);
 		e_cal_component_set_recurid (pitip->comp, recur_id);
-	} else
-       		e_cal_component_free_datetime (&datetime);
+		g_free (recur_id); /* it's ok to call g_free here */
+	}
+	e_cal_component_free_datetime (&datetime);
 
 	e_cal_component_get_dtend (pitip->comp, &datetime);
 	pitip->end_time = 0;

Modified: trunk/plugins/save-calendar/csv-format.c
==============================================================================
--- trunk/plugins/save-calendar/csv-format.c	(original)
+++ trunk/plugins/save-calendar/csv-format.c	Fri Jan 25 14:10:07 2008
@@ -462,18 +462,15 @@
 
 			e_cal_component_get_dtstart (comp, &temp_dt);
 			line = add_time_to_csv (line, temp_dt.value ? temp_dt.value : NULL, config);
-			if (temp_dt.value)
-				e_cal_component_free_datetime (&temp_dt);
+			e_cal_component_free_datetime (&temp_dt);
 
 			e_cal_component_get_dtend (comp, &temp_dt);
 			line = add_time_to_csv (line, temp_dt.value ? temp_dt.value : NULL, config);
-			if (temp_dt.value)
-				e_cal_component_free_datetime (&temp_dt);
+			e_cal_component_free_datetime (&temp_dt);
 
 			e_cal_component_get_due (comp, &temp_dt);
 			line = add_time_to_csv (line, temp_dt.value ? temp_dt.value : NULL, config);
-			if (temp_dt.value)
-				e_cal_component_free_datetime (&temp_dt);
+			e_cal_component_free_datetime (&temp_dt);
 
 			e_cal_component_get_percent (comp, &temp_int);
 			line = add_nummeric_to_csv (line, temp_int, config);

Modified: trunk/plugins/save-calendar/rdf-format.c
==============================================================================
--- trunk/plugins/save-calendar/rdf-format.c	(original)
+++ trunk/plugins/save-calendar/rdf-format.c	Fri Jan 25 14:10:07 2008
@@ -320,19 +320,16 @@
 				e_cal_component_free_text_list (temp_list);
 
 			e_cal_component_get_dtstart (comp, &temp_dt);
-			 add_time_to_rdf (node, "dtstart", temp_dt.value ? temp_dt.value : NULL);
-			if (temp_dt.value)
-				e_cal_component_free_datetime (&temp_dt);
+			add_time_to_rdf (node, "dtstart", temp_dt.value ? temp_dt.value : NULL);
+			e_cal_component_free_datetime (&temp_dt);
 
 			e_cal_component_get_dtend (comp, &temp_dt);
 			add_time_to_rdf (node, "dtend", temp_dt.value ? temp_dt.value : NULL);
-			if (temp_dt.value)
-				e_cal_component_free_datetime (&temp_dt);
+			e_cal_component_free_datetime (&temp_dt);
 
 			e_cal_component_get_due (comp, &temp_dt);
 			add_time_to_rdf (node, "due", temp_dt.value ? temp_dt.value : NULL);
-			if (temp_dt.value)
-				e_cal_component_free_datetime (&temp_dt);
+			e_cal_component_free_datetime (&temp_dt);
 
 			e_cal_component_get_percent (comp, &temp_int);
 			add_nummeric_to_rdf (node, "percentComplete", temp_int);



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