[libdazzle] signal-group: be more tolerant of unconnected handlers



commit 47d005d0d386deb19a54a762ec9c948add7e62ad
Author: Christian Hergert <chergert redhat com>
Date:   Sun Aug 20 12:31:07 2017 -0700

    signal-group: be more tolerant of unconnected handlers
    
    It might be possible to get into this situation if new connections are
    made after an object has been bound. It's not exactly the ideal use case
    but we also don't forbid it.

 src/bindings/dzl-signal-group.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/src/bindings/dzl-signal-group.c b/src/bindings/dzl-signal-group.c
index c3ae340..d75f702 100644
--- a/src/bindings/dzl-signal-group.c
+++ b/src/bindings/dzl-signal-group.c
@@ -249,19 +249,22 @@ dzl_signal_group_unbind (DzlSignalGroup *self)
   for (i = 0; i < self->handlers->len; i++)
     {
       SignalHandler *handler;
-      gulong handler_id;
 
       handler = g_ptr_array_index (self->handlers, i);
 
       g_assert (handler != NULL);
       g_assert (handler->signal_id != 0);
       g_assert (handler->closure != NULL);
-      g_assert (handler->handler_id != 0);
 
-      handler_id = handler->handler_id;
-      handler->handler_id = 0;
+      if (handler->handler_id != 0)
+        {
+          gulong handler_id;
 
-      g_signal_handler_disconnect (target, handler_id);
+          handler_id = handler->handler_id;
+          handler->handler_id = 0;
+
+          g_signal_handler_disconnect (target, handler_id);
+        }
     }
 
   g_signal_emit (self, signals [UNBIND], 0);


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