[libhandy] animation: Stop using g_signal_handlers_disconnect_by_func()



commit 0a3370123c19fdacdfcb31730e13a34967afc246
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Wed Mar 24 14:24:26 2021 +0500

    animation: Stop using g_signal_handlers_disconnect_by_func()
    
    Be more specific when disconnecting the signal, there are instances where
    we'd get criticals otherwise.

 src/hdy-animation.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/hdy-animation.c b/src/hdy-animation.c
index c54aff86..eef43c63 100644
--- a/src/hdy-animation.c
+++ b/src/hdy-animation.c
@@ -34,6 +34,7 @@ struct _HdyAnimation
 
   gint64 start_time; /* ms */
   guint tick_cb_id;
+  gulong unmap_cb_id;
 
   HdyAnimationEasingFunc easing_func;
   HdyAnimationValueCallback value_cb;
@@ -74,7 +75,10 @@ tick_cb (GtkWidget     *widget,
 
     set_value (self, self->value_to);
 
-    g_signal_handlers_disconnect_by_func (self->widget, hdy_animation_stop, self);
+    if (self->unmap_cb_id) {
+      g_signal_handler_disconnect (self->widget, self->unmap_cb_id);
+      self->unmap_cb_id = 0;
+    }
 
     done (self);
 
@@ -169,8 +173,9 @@ hdy_animation_start (HdyAnimation *self)
   if (self->tick_cb_id)
     return;
 
-  g_signal_connect_swapped (self->widget, "unmap",
-                            G_CALLBACK (hdy_animation_stop), self);
+  self->unmap_cb_id =
+    g_signal_connect_swapped (self->widget, "unmap",
+                              G_CALLBACK (hdy_animation_stop), self);
   self->tick_cb_id = gtk_widget_add_tick_callback (self->widget, (GtkTickCallback) tick_cb, self, NULL);
 }
 
@@ -182,8 +187,11 @@ hdy_animation_stop (HdyAnimation *self)
   if (self->tick_cb_id) {
     gtk_widget_remove_tick_callback (self->widget, self->tick_cb_id);
     self->tick_cb_id = 0;
+  }
 
-    g_signal_handlers_disconnect_by_func (self->widget, hdy_animation_stop, self);
+  if (self->unmap_cb_id) {
+    g_signal_handler_disconnect (self->widget, self->unmap_cb_id);
+    self->unmap_cb_id = 0;
   }
 
   done (self);


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