Fix crashes when e_cal_util_get_system_timezone() returns NULL

The return value is nullable, but gnome-calendar fails to check it.

Because the nullable return value is inconvenient for us, we can instead
add and use gcal_context_get_icaltimezone() to supplement the existing
gcal_context_get_timezone().

We'll also need a function to convert from GTimeZone to ICalTimezone,
gcal_timezone_to_icaltimezone().

Fixes #419
This commit is contained in:
Michael Catanzaro
2019-09-19 16:01:44 -05:00
parent d0d4166d23
commit 8e6a3b9f3f
6 changed files with 94 additions and 18 deletions
+20
View File
@@ -230,3 +230,23 @@ gcal_date_time_from_icaltime (const ICalTime *date)
return g_steal_pointer (&dt);
}
/**
* @tz: a #GTimezone
*
* Returns an #ICalTimezone corresponding to @tz.
*
* Returns: (transfer none): an #ICalTimezone.
*/
ICalTimezone*
gcal_timezone_to_icaltimezone (GTimeZone *tz)
{
ICalTimezone *ical_tz;
const gchar *tzid;
tzid = g_time_zone_get_identifier (tz);
ical_tz = i_cal_timezone_get_builtin_timezone (tzid);
g_assert (ical_tz != NULL);
return ical_tz;
}