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 */
|
||||
|
||||
+32
-4
@@ -18,6 +18,8 @@
|
||||
|
||||
#define G_LOG_DOMAIN "GcalManager"
|
||||
|
||||
#include "gcal-application.h"
|
||||
#include "gcal-context.h"
|
||||
#include "gcal-debug.h"
|
||||
#include "gcal-manager.h"
|
||||
#include "gcal-utils.h"
|
||||
@@ -877,11 +879,18 @@ void
|
||||
gcal_manager_setup_shell_search (GcalManager *self,
|
||||
ECalDataModelSubscriber *subscriber)
|
||||
{
|
||||
GcalApplication *application;
|
||||
GcalContext *context;
|
||||
GTimeZone *zone;
|
||||
|
||||
g_return_if_fail (GCAL_IS_MANAGER (self));
|
||||
|
||||
if (self->shell_search_data_model)
|
||||
return;
|
||||
|
||||
application = GCAL_APPLICATION (g_application_get_default ());
|
||||
context = gcal_application_get_context (application);
|
||||
|
||||
self->shell_search_data_model = e_cal_data_model_new (gcal_thread_submit_job);
|
||||
g_signal_connect_object (self->shell_search_data_model,
|
||||
"view-state-changed",
|
||||
@@ -890,7 +899,9 @@ gcal_manager_setup_shell_search (GcalManager *self,
|
||||
G_CONNECT_SWAPPED);
|
||||
|
||||
e_cal_data_model_set_expand_recurrences (self->shell_search_data_model, TRUE);
|
||||
e_cal_data_model_set_timezone (self->shell_search_data_model, e_cal_util_get_system_timezone ());
|
||||
|
||||
zone = gcal_context_get_timezone (context);
|
||||
e_cal_data_model_set_timezone (self->shell_search_data_model, gcal_timezone_to_icaltimezone (zone));
|
||||
|
||||
self->search_view_data = g_new0 (ViewStateData, 1);
|
||||
self->search_view_data->subscriber = subscriber;
|
||||
@@ -1420,7 +1431,11 @@ gcal_manager_get_events (GcalManager *self,
|
||||
ICalTime *start_date,
|
||||
ICalTime *end_date)
|
||||
{
|
||||
GcalApplication *application;
|
||||
GcalContext *context;
|
||||
time_t range_start, range_end;
|
||||
GTimeZone *zone;
|
||||
ICalTimezone *tz;
|
||||
GatherEventData data = {
|
||||
.manager = self,
|
||||
.events = NULL,
|
||||
@@ -1428,10 +1443,15 @@ gcal_manager_get_events (GcalManager *self,
|
||||
|
||||
GCAL_ENTRY;
|
||||
|
||||
application = GCAL_APPLICATION (g_application_get_default ());
|
||||
context = gcal_application_get_context (application);
|
||||
|
||||
g_return_val_if_fail (GCAL_IS_MANAGER (self), NULL);
|
||||
|
||||
range_start = i_cal_time_as_timet_with_zone (start_date, e_cal_util_get_system_timezone ());
|
||||
range_end = i_cal_time_as_timet_with_zone (end_date, e_cal_util_get_system_timezone ());
|
||||
zone = gcal_context_get_timezone (context);
|
||||
tz = gcal_timezone_to_icaltimezone (zone);
|
||||
range_start = i_cal_time_as_timet_with_zone (start_date, tz);
|
||||
range_end = i_cal_time_as_timet_with_zone (end_date, tz);
|
||||
|
||||
e_cal_data_model_foreach_component (self->e_data_model,
|
||||
range_start,
|
||||
@@ -1521,9 +1541,15 @@ gcal_manager_startup (GcalManager *self)
|
||||
GList *sources, *l;
|
||||
GError *error = NULL;
|
||||
ESourceCredentialsProvider *credentials_provider;
|
||||
GcalApplication *application;
|
||||
GcalContext *context;
|
||||
GTimeZone *zone;
|
||||
|
||||
GCAL_ENTRY;
|
||||
|
||||
application = GCAL_APPLICATION (g_application_get_default ());
|
||||
context = gcal_application_get_context (application);
|
||||
|
||||
self->clients = g_hash_table_new_full ((GHashFunc) e_source_hash,
|
||||
(GEqualFunc) e_source_equal,
|
||||
g_object_unref,
|
||||
@@ -1621,7 +1647,9 @@ gcal_manager_startup (GcalManager *self)
|
||||
self->e_data_model = e_cal_data_model_new (gcal_thread_submit_job);
|
||||
|
||||
e_cal_data_model_set_expand_recurrences (self->e_data_model, TRUE);
|
||||
e_cal_data_model_set_timezone (self->e_data_model, e_cal_util_get_system_timezone ());
|
||||
|
||||
zone = gcal_context_get_timezone (context);
|
||||
e_cal_data_model_set_timezone (self->e_data_model, gcal_timezone_to_icaltimezone (zone));
|
||||
|
||||
sources = e_source_registry_list_enabled (self->source_registry, E_SOURCE_EXTENSION_CALENDAR);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user