[glib: 14/19] gsignal: Clarify signal detail format



commit 5e89ba5a742ecbd5910a2bb4e963159ce076ae39
Author: Philip Withnall <withnall endlessm com>
Date:   Tue Nov 12 20:59:40 2019 +0000

    gsignal: Clarify signal detail format
    
    The format has never previously been specified. It can be anything, but
    for sanity’s sake disallow empty strings.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    Helps: #358

 gobject/gsignal.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/gobject/gsignal.c b/gobject/gsignal.c
index 43949c580..579eb4846 100644
--- a/gobject/gsignal.c
+++ b/gobject/gsignal.c
@@ -98,6 +98,10 @@
  * detail part of the signal specification upon connection) serves as a
  * wildcard and matches any detail argument passed in to emission.
  *
+ * While the @detail argument is typically used to pass an object property name
+ * (as with #GObject::notify), no specific format is mandated for the detail
+ * string, other than that it must be non-empty.
+ *
  * ## Memory management of signal handlers # {#signal-memory-management}
  *
  * If you are connecting handlers to signals and using a #GObject instance as
@@ -1158,6 +1162,9 @@ signal_parse_name (const gchar *name,
       gchar buffer[32];
       guint l = colon - name;
       
+      if (colon[2] == '\0')
+        return 0;
+
       if (l < 32)
        {
          memcpy (buffer, name, l);
@@ -1175,7 +1182,7 @@ signal_parse_name (const gchar *name,
        }
       
       if (signal_id && detail_p)
-       *detail_p = colon[2] ? (force_quark ? g_quark_from_string : g_quark_try_string) (colon + 2) : 0;
+        *detail_p = (force_quark ? g_quark_from_string : g_quark_try_string) (colon + 2);
     }
   else
     signal_id = 0;


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