Blob Blame History Raw
From 1f8f91f598bf04c174f5045d8716aeda16bd56b9 Mon Sep 17 00:00:00 2001
From: Michael Catanzaro <mcatanzaro@igalia.com>
Date: Wed, 3 Jul 2019 11:47:55 -0500
Subject: [PATCH] Properly disconnect GcalWeatherService from its GWeatherInfo

We fail to disconnect from the GWeatherInfo in both update_location() and
dispose. We have to fix update_location() manually. To avoid the need to
disconnect in dispose, we can just use g_signal_connect_object().
---
 src/weather/gcal-weather-service.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/weather/gcal-weather-service.c b/src/weather/gcal-weather-service.c
index 5ca08a27..828a89bc 100644
--- a/src/weather/gcal-weather-service.c
+++ b/src/weather/gcal-weather-service.c
@@ -476,7 +476,11 @@ update_location (GcalWeatherService  *self,
   if (gcal_timer_is_running (self->duration_timer))
     stop_timer (self);
 
-  g_clear_object (&self->gweather_info);
+  if (self->gweather_info != NULL)
+    {
+      g_signal_handlers_disconnect_by_data (self->gweather_info, self);
+      g_clear_object (&self->gweather_info);
+    }
 
   if (!location)
     {
@@ -496,7 +500,7 @@ update_location (GcalWeatherService  *self,
        * what is going on.
        */
       gweather_info_set_enabled_providers (self->gweather_info, GWEATHER_PROVIDER_METAR | GWEATHER_PROVIDER_OWM | GWEATHER_PROVIDER_YR_NO);
-      g_signal_connect (self->gweather_info, "updated", (GCallback) on_gweather_update_cb, self);
+      g_signal_connect_object (self->gweather_info, "updated", (GCallback) on_gweather_update_cb, self, 0);
 
       /*
        * gweather_info_update might or might not trigger a
-- 
2.21.0