[glib/another-victim-of-gobject: 1/2] gobject: Don't skip custom dispatch_properties_changed




commit 62818ef29d9ffdb389927d98625e42d202e0db4a
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jul 2 15:24:29 2022 -0400

    gobject: Don't skip custom dispatch_properties_changed
    
    When I optimized GObject to skip property notification
    in some cases, I looked for whether the class has a
    custom notify vfunc. I overlooked that that
    dispatch_properties_changed can also be customized,
    and if it is, we better not skip change notification.
    
    This showed up as breakage in the adjustment tests
    in the GTK testsuite.

 gobject/gobject.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 1c6bfedfae..e5320d806d 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -152,6 +152,10 @@
 #define CLASS_HAS_CUSTOM_CONSTRUCTED(class) \
     ((class)->constructed != g_object_constructed)
 #define CLASS_HAS_NOTIFY(class) ((class)->notify != NULL)
+#define CLASS_HAS_CUSTOM_DISPATCH(class) \
+    ((class)->dispatch_properties_changed != g_object_dispatch_properties_changed)
+#define CLASS_NEEDS_NOTIFY(class) \
+    (CLASS_HAS_NOTIFY(class) || CLASS_HAS_CUSTOM_DISPATCH(class))
 
 #define CLASS_HAS_DERIVED_CLASS_FLAG 0x2
 #define CLASS_HAS_DERIVED_CLASS(class) \
@@ -1237,7 +1241,7 @@ static inline gboolean
 _g_object_has_notify_handler (GObject *object)
 {
 #ifdef HAVE_OPTIONAL_FLAGS
-  return CLASS_HAS_NOTIFY (G_OBJECT_GET_CLASS (object)) ||
+  return CLASS_NEEDS_NOTIFY (G_OBJECT_GET_CLASS (object)) ||
          (object_get_optional_flags (object) & OPTIONAL_FLAG_HAS_NOTIFY_HANDLER) != 0;
 #else
   return TRUE;
@@ -1248,7 +1252,7 @@ static inline gboolean
 _g_object_has_notify_handler_X (GObject *object)
 {
 #ifdef HAVE_OPTIONAL_FLAGS
-  return CLASS_HAS_NOTIFY (G_OBJECT_GET_CLASS (object)) ||
+  return CLASS_NEEDS_NOTIFY (G_OBJECT_GET_CLASS (object)) ||
          (object_get_optional_flags_X (object) & OPTIONAL_FLAG_HAS_NOTIFY_HANDLER) != 0;
 #else
   return TRUE;
@@ -1304,7 +1308,7 @@ g_object_init (GObject            *object,
   object->ref_count = 1;
   object->qdata = NULL;
 
-  if (CLASS_HAS_PROPS (class) && CLASS_HAS_NOTIFY (class))
+  if (CLASS_HAS_PROPS (class) && CLASS_NEEDS_NOTIFY (class))
     {
       /* freeze object's notification queue, g_object_new_internal() preserves pairedness */
       g_object_notify_queue_freeze (object, FALSE);
@@ -1478,7 +1482,7 @@ g_object_notify_by_spec_internal (GObject    *object,
 #ifdef HAVE_OPTIONAL_FLAGS
   guint object_flags;
 #endif
-  gboolean has_notify;
+  gboolean needs_notify;
   gboolean in_init;
 
   if (G_UNLIKELY (~pspec->flags & G_PARAM_READABLE))
@@ -1489,15 +1493,15 @@ g_object_notify_by_spec_internal (GObject    *object,
 #ifdef HAVE_OPTIONAL_FLAGS
   /* get all flags we need with a single atomic read */
   object_flags = object_get_optional_flags (object);
-  has_notify = ((object_flags & OPTIONAL_FLAG_HAS_NOTIFY_HANDLER) != 0) ||
-               CLASS_HAS_NOTIFY (G_OBJECT_GET_CLASS (object));
+  needs_notify = ((object_flags & OPTIONAL_FLAG_HAS_NOTIFY_HANDLER) != 0) ||
+                  CLASS_NEEDS_NOTIFY (G_OBJECT_GET_CLASS (object));
   in_init = (object_flags & OPTIONAL_FLAG_IN_CONSTRUCTION) != 0;
 #else
-  has_notify = TRUE;
+  needs_notify = TRUE;
   in_init = object_in_construction (object);
 #endif
 
-  if (pspec != NULL && has_notify)
+  if (pspec != NULL && needs_notify)
     {
       GObjectNotifyQueue *nqueue;
       gboolean need_thaw = TRUE;


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