[glib] gobject: add 'explicit notify' GParamSpec flag



commit bbdb2345fc7e5a57cb7af90ab0bf8ced437ada24
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Jun 4 08:59:50 2014 -0400

    gobject: add 'explicit notify' GParamSpec flag
    
    Add a flag to prevent the automatic emission of the "notify" signal
    during g_object_set_property().
    
    If this flag is set then the class must explicitly emit the notify
    for themselves.  This is already standard practice on most classes, but
    we cannot simply remove the existing behaviour because there are surely
    many cases where it is needed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=731200

 gobject/gobject.c |   13 ++++++++-----
 gobject/gparam.h  |    5 +++++
 2 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 4a35cd0..7e9e467 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -1380,14 +1380,17 @@ object_set_property (GObject             *object,
     }
   else
     {
-      GParamSpec *notify_pspec;
-
       class->set_property (object, param_id, &tmp_value, pspec);
 
-      notify_pspec = get_notify_pspec (pspec);
+      if (~pspec->flags & G_PARAM_EXPLICIT_NOTIFY)
+        {
+          GParamSpec *notify_pspec;
+
+          notify_pspec = get_notify_pspec (pspec);
 
-      if (notify_pspec != NULL)
-        g_object_notify_queue_add (object, nqueue, notify_pspec);
+          if (notify_pspec != NULL)
+            g_object_notify_queue_add (object, nqueue, notify_pspec);
+        }
     }
   g_value_unset (&tmp_value);
 }
diff --git a/gobject/gparam.h b/gobject/gparam.h
index fb21f7b..8f216e4 100644
--- a/gobject/gparam.h
+++ b/gobject/gparam.h
@@ -130,6 +130,10 @@ G_BEGIN_DECLS
  *  parameter is guaranteed to remain valid and 
  *  unmodified for the lifetime of the parameter. 
  *  Since 2.8
+ * @G_PARAM_EXPLICIT_NOTIFY: calls to g_object_set_property() for this
+ *   property will not automatically result in a "notify" signal being
+ *   emitted: the implementation must call g_object_notify() themselves
+ *   in case the property actually changes.  Since: 2.42.
  * @G_PARAM_PRIVATE: internal
  * @G_PARAM_DEPRECATED: the parameter is deprecated and will be removed
  *  in a future version. A warning will be generated if it is used
@@ -153,6 +157,7 @@ typedef enum
 #endif
   G_PARAM_STATIC_NICK        = 1 << 6,
   G_PARAM_STATIC_BLURB       = 1 << 7,
+  G_PARAM_EXPLICIT_NOTIFY     = 1 << 8,
   /* User defined flags go up to 30 */
   G_PARAM_DEPRECATED          = 1 << 31
 } GParamFlags;


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