Blame SOURCES/evolution-3.40.4-comp-editor-timezone-reset.patch

fdb210
From 9bbb9289477c8a61a641b0b67cec367629f1e73a Mon Sep 17 00:00:00 2001
fdb210
From: Milan Crha <mcrha@redhat.com>
fdb210
Date: Thu, 10 Feb 2022 11:59:36 +0100
fdb210
Subject: [PATCH] ECompEditor: Timezone can be reset on component save
fdb210
fdb210
The libical 3.0.14 contains a change, which unsets non-UTC timezones
fdb210
in date/time values. That uncovered a bug in the Evolution code, which
fdb210
expects the timezone will be preserved on re-read from the component,
fdb210
but it's not always possible. This is corrected by re-setting the timezone
fdb210
on the used ICalTime value.
fdb210
---
fdb210
 src/calendar/gui/e-comp-editor-property-part.c | 18 ++++++++++++++++++
fdb210
 1 file changed, 18 insertions(+)
fdb210
fdb210
diff --git a/src/calendar/gui/e-comp-editor-property-part.c b/src/calendar/gui/e-comp-editor-property-part.c
fdb210
index 6bed833b12..6ce699a2e6 100644
fdb210
--- a/src/calendar/gui/e-comp-editor-property-part.c
fdb210
+++ b/src/calendar/gui/e-comp-editor-property-part.c
fdb210
@@ -913,8 +913,15 @@ ecepp_datetime_fill_component (ECompEditorPropertyPart *property_part,
fdb210
 			g_object_unref (prop);
fdb210
 		}
fdb210
 	} else {
fdb210
+		ICalTimezone *zone;
fdb210
+
fdb210
 		value = e_comp_editor_property_part_datetime_get_value (part_datetime);
fdb210
 
fdb210
+		zone = value && !i_cal_time_is_null_time (value) ? i_cal_time_get_timezone (value) : NULL;
fdb210
+
fdb210
+		if (zone)
fdb210
+			g_object_ref (zone);
fdb210
+
fdb210
 		if (prop) {
fdb210
 			/* Remove the VALUE parameter, to correspond to the actual value being set */
fdb210
 			i_cal_property_remove_parameter_by_kind (prop, I_CAL_VALUE_PARAMETER);
fdb210
@@ -925,6 +932,11 @@ ecepp_datetime_fill_component (ECompEditorPropertyPart *property_part,
fdb210
 			g_clear_object (&value);
fdb210
 			value = klass->i_cal_get_func (prop);
fdb210
 
fdb210
+			/* The timezone can be dropped since libical 3.0.14, thus restore it
fdb210
+			   before updating the TZID parameter */
fdb210
+			if (zone && value && !i_cal_time_is_null_time (value) && !i_cal_time_is_date (value))
fdb210
+				i_cal_time_set_timezone (value, zone);
fdb210
+
fdb210
 			cal_comp_util_update_tzid_parameter (prop, value);
fdb210
 		} else {
fdb210
 			prop = klass->i_cal_new_func (value);
fdb210
@@ -933,12 +945,18 @@ ecepp_datetime_fill_component (ECompEditorPropertyPart *property_part,
fdb210
 			g_clear_object (&value);
fdb210
 			value = klass->i_cal_get_func (prop);
fdb210
 
fdb210
+			/* The timezone can be dropped since libical 3.0.14, thus restore it
fdb210
+			   before updating the TZID parameter */
fdb210
+			if (zone && value && !i_cal_time_is_null_time (value) && !i_cal_time_is_date (value))
fdb210
+				i_cal_time_set_timezone (value, zone);
fdb210
+
fdb210
 			cal_comp_util_update_tzid_parameter (prop, value);
fdb210
 			i_cal_component_add_property (component, prop);
fdb210
 		}
fdb210
 
fdb210
 		g_clear_object (&value);
fdb210
 		g_clear_object (&prop);
fdb210
+		g_clear_object (&zone);
fdb210
 	}
fdb210
 }
fdb210
 
fdb210
-- 
fdb210
2.33.1
fdb210