From 3ed9669c6e50afffe4a2aca448e46cfdf92b6722 Mon Sep 17 00:00:00 2001 From: Michael Catanzaro Date: Wed, 3 Jul 2019 11:57:35 -0500 Subject: [PATCH] week-header: Remove internal weather service self->weather_service was only partially removed in 01fdf79e6a, leading to a guaranteed crash when the weather is updated because self->weather_service is now always NULL. Fixes #397 --- src/views/gcal-week-header.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/views/gcal-week-header.c b/src/views/gcal-week-header.c index a50f8da0..dd68375e 100644 --- a/src/views/gcal-week-header.c +++ b/src/views/gcal-week-header.c @@ -95,7 +95,6 @@ struct _GcalWeekHeader gint selection_end; gint dnd_cell; - GcalWeatherService *weather_service; /* unowned, nullable */ /* Array of nullable weather infos for each day, starting with Sunday. */ WeatherInfoDay weather_infos[7]; @@ -195,16 +194,17 @@ clear_weather_infos (GcalWeekHeader *self) static void update_weather_infos (GcalWeekHeader *self) { - GPtrArray* weather_infos; + GPtrArray *weather_infos; + GcalWeatherService *service; g_return_if_fail (GCAL_IS_WEEK_HEADER (self)); clear_weather_infos (self); - if (!self->weather_service) - return; + g_assert (self->context); + service = gcal_context_get_weather_service (self->context); - weather_infos = gcal_weather_service_get_weather_infos (self->weather_service); + weather_infos = gcal_weather_service_get_weather_infos (service); add_weather_infos (self, weather_infos); } @@ -353,7 +353,6 @@ on_weather_update (GcalWeatherService *weather_service, { g_assert (GCAL_IS_WEATHER_SERVICE (weather_service)); g_assert (GCAL_IS_WEEK_HEADER (self)); - g_assert (self->weather_service == weather_service); update_weather_infos (self); } @@ -1162,8 +1161,6 @@ gcal_week_header_finalize (GObject *object) for (i = 0; i < 7; i++) g_list_free (self->events[i]); - g_clear_object (&self->weather_service); - for (i = 0; i < G_N_ELEMENTS (self->weather_infos); i++) wid_clear (&self->weather_infos[i]); }