[gtk/builder-notify] Freeze notify queue when building objects



commit 001c0a35ce0e250661e9a2aa8776726215b5fb31
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Wed Sep 4 11:05:12 2019 +0100

    Freeze notify queue when building objects
    
    We're potentially applying multiple properties during object
    construction; we should avoid constantly notifying after setting each
    one, and instead coalesce the notifications at the end. In most cases,
    the calling code doesn't have access to the instance, so it won't be
    able to connect to the "notify" signal anyway, but it avoids a lot of
    busy work.

 gtk/gtkbuilder.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 619aa07e95..78be3d10c0 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -742,6 +742,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
           g_value_unset (&param->value);
         }
     }
+
   g_array_free (construct_parameters, TRUE);
 
   custom_set_property = FALSE;
@@ -755,6 +756,11 @@ G_GNUC_END_IGNORE_DEPRECATIONS
         custom_set_property = TRUE;
     }
 
+  /* We're going to set multiple properties in one go, so it's better
+   * to notify changes at the end
+   */
+  g_object_freeze_notify (obj);
+
   for (i = 0; i < parameters->len; i++)
     {
       GParameter *param = &g_array_index (parameters, GParameter, i);
@@ -773,6 +779,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 #endif
       g_value_unset (&param->value);
     }
+
+  g_object_thaw_notify (obj);
+
   g_array_free (parameters, TRUE);
 
   if (info->bindings)
@@ -819,6 +828,8 @@ _gtk_builder_apply_properties (GtkBuilder  *builder,
         custom_set_property = TRUE;
     }
 
+  g_object_freeze_notify (info->object);
+
   for (i = 0; i < parameters->len; i++)
     {
       GParameter *param = &g_array_index (parameters, GParameter, i);
@@ -837,6 +848,9 @@ _gtk_builder_apply_properties (GtkBuilder  *builder,
 #endif
       g_value_unset (&param->value);
     }
+
+  g_object_thaw_notify (info->object);
+
   g_array_free (parameters, TRUE);
 }
 


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