[gnome-calendar] view: Auto disconnect weather-changed signal handler



commit 9d0b44d4e3c321a59a02443dd16a25354d09bbd6
Author: Andrea Azzarone <azzaronea gmail com>
Date:   Mon Apr 9 13:02:08 2018 +0200

    view: Auto disconnect weather-changed signal handler
    
    Use g_signal_connect_object in order to auto disconnect the weather-changed
    signal handler when the view object is finalized.
    
    https://gitlab.gnome.org/GNOME/gnome-calendar/issues/271

 src/views/gcal-month-view.c  | 3 ---
 src/views/gcal-view.c        | 2 +-
 src/views/gcal-week-header.c | 8 +-------
 3 files changed, 2 insertions(+), 11 deletions(-)
---
diff --git a/src/views/gcal-month-view.c b/src/views/gcal-month-view.c
index 5c28cb09..5d77f8c6 100644
--- a/src/views/gcal-month-view.c
+++ b/src/views/gcal-month-view.c
@@ -1795,9 +1795,6 @@ gcal_month_view_finalize (GObject *object)
 {
   GcalMonthView *self = GCAL_MONTH_VIEW (object);
 
-  if (self->weather_service)
-    g_signal_handlers_disconnect_by_func (self->weather_service, weather_changed_cb, self);
-
   g_clear_pointer (&self->date, g_free);
   g_clear_pointer (&self->children, g_hash_table_destroy);
   g_clear_pointer (&self->single_cell_children, g_hash_table_destroy);
diff --git a/src/views/gcal-view.c b/src/views/gcal-view.c
index fefefdc5..716fdb7b 100644
--- a/src/views/gcal-view.c
+++ b/src/views/gcal-view.c
@@ -218,7 +218,7 @@ gcal_view_set_weather_service_impl_helper (GcalWeatherService  **old_service,
       g_set_object (old_service, new_service);
 
       if (*old_service)
-        g_signal_connect (*old_service, "weather-changed", weather_changed_cb, data);
+        g_signal_connect_object (*old_service, "weather-changed", weather_changed_cb, data, 0);
 
       update_func (data);
       g_object_notify (G_OBJECT (data), "weather-service");
diff --git a/src/views/gcal-week-header.c b/src/views/gcal-week-header.c
index 654001b5..a62744c8 100644
--- a/src/views/gcal-week-header.c
+++ b/src/views/gcal-week-header.c
@@ -1095,13 +1095,7 @@ gcal_week_header_finalize (GObject *object)
   for (i = 0; i < 7; i++)
     g_list_free (self->events[i]);
 
-  if (self->weather_service != NULL)
-    {
-      g_signal_handlers_disconnect_by_func (self->weather_service,
-                                            (GCallback) on_weather_update,
-                                            self);
-      g_clear_object (&self->weather_service);
-    }
+  g_clear_object (&self->weather_service);
 
   for (i = 0; i < G_N_ELEMENTS (self->weather_infos); i++)
     wid_clear (&self->weather_infos[i]);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]