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:
+12
-4
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "gconstructor.h"
|
||||
#include "gcal-application.h"
|
||||
#include "gcal-context.h"
|
||||
#include "gcal-debug.h"
|
||||
#include "gcal-event.h"
|
||||
#include "gcal-utils.h"
|
||||
@@ -223,12 +224,17 @@ static ECalComponentDateTime*
|
||||
build_component_from_datetime (GcalEvent *self,
|
||||
GDateTime *dt)
|
||||
{
|
||||
GcalApplication *application;
|
||||
GcalContext *context;
|
||||
ICalTime *itt;
|
||||
gchar *tzid;
|
||||
|
||||
if (!dt)
|
||||
return NULL;
|
||||
|
||||
application = GCAL_APPLICATION (g_application_get_default ());
|
||||
context = gcal_application_get_context (application);
|
||||
|
||||
itt = gcal_date_time_to_icaltime (dt);
|
||||
|
||||
if (self->all_day)
|
||||
@@ -238,11 +244,13 @@ build_component_from_datetime (GcalEvent *self,
|
||||
}
|
||||
else
|
||||
{
|
||||
ICalTimezone *zone;
|
||||
ICalTimezone *tz;
|
||||
GTimeZone *zone;
|
||||
|
||||
zone = e_cal_util_get_system_timezone ();
|
||||
i_cal_time_set_timezone (itt, zone);
|
||||
tzid = zone ? g_strdup (i_cal_timezone_get_tzid (zone)) : NULL;
|
||||
zone = gcal_context_get_timezone (context);
|
||||
tz = gcal_timezone_to_icaltimezone (zone);
|
||||
i_cal_time_set_timezone (itt, tz);
|
||||
tzid = g_strdup (i_cal_timezone_get_tzid (tz));
|
||||
}
|
||||
|
||||
/* Call it after setting the timezone, because the DATE values do not let set the timezone */
|
||||
|
||||
Reference in New Issue
Block a user