[gtk/builder-binding-ordering] builder: Fix handling of <binding>
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/builder-binding-ordering] builder: Fix handling of <binding>
- Date: Tue, 28 Sep 2021 18:08:52 +0000 (UTC)
commit 4ce6cb863c9434cb8251a2cf17ac76ee9a79f30c
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Sep 28 13:47:15 2021 -0400
builder: Fix handling of <binding>
We were only applying <binding> elements when the
object is constructed, which can be triggered by
various things (e.g. a <style> element). Defer
this until we reach </object>, so we can be sure
that we pick up all the bindings.
Testcase included.
Fixes: #4147
gtk/gtkbuilder.c | 5 +----
gtk/gtkbuilderparser.c | 6 ++++++
gtk/gtkbuilderprivate.h | 4 ++++
testsuite/reftests/meson.build | 2 ++
4 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 47af4df1fe..fef468e8bb 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -699,7 +699,7 @@ _gtk_builder_add_object (GtkBuilder *builder,
g_hash_table_insert (priv->objects, g_strdup (id), g_object_ref (object));
}
-static void
+void
gtk_builder_take_bindings (GtkBuilder *builder,
GObject *target,
GSList *bindings)
@@ -926,9 +926,6 @@ _gtk_builder_construct (GtkBuilder *builder,
object_properties_destroy (¶meters);
- if (info->bindings)
- gtk_builder_take_bindings (builder, obj, info->bindings);
-
/* put it in the hash table. */
_gtk_builder_add_object (builder, info->id, obj);
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index f91523d598..ccfb1cbc56 100644
--- a/gtk/gtkbuilderparser.c
+++ b/gtk/gtkbuilderparser.c
@@ -1962,6 +1962,12 @@ end_element (GtkBuildableParseContext *context,
object_info->signals = NULL;
}
+ if (object_info->bindings)
+ {
+ gtk_builder_take_bindings (data->builder, object_info->object, object_info->bindings);
+ object_info->bindings = NULL;
+ }
+
free_object_info (object_info);
}
else if (strcmp (element_name, "child") == 0)
diff --git a/gtk/gtkbuilderprivate.h b/gtk/gtkbuilderprivate.h
index 32cb470f4b..e99b7163e6 100644
--- a/gtk/gtkbuilderprivate.h
+++ b/gtk/gtkbuilderprivate.h
@@ -221,6 +221,10 @@ void _gtk_builder_add (GtkBuilder *builder,
ChildInfo *child_info);
void _gtk_builder_add_signals (GtkBuilder *builder,
GPtrArray *signals);
+void gtk_builder_take_bindings (GtkBuilder *builder,
+ GObject *target,
+ GSList *bindings);
+
gboolean _gtk_builder_finish (GtkBuilder *builder,
GError **error);
void _free_signal_info (SignalInfo *info,
diff --git a/testsuite/reftests/meson.build b/testsuite/reftests/meson.build
index e4e860fc9f..6806ece031 100644
--- a/testsuite/reftests/meson.build
+++ b/testsuite/reftests/meson.build
@@ -331,6 +331,8 @@ testdata = [
# that are not valid with subpixel positioning
#'label-wrap-justify.ref.ui',
#'label-wrap-justify.ui',
+ 'late-binding.ui',
+ 'late-binding.ref.ui',
'late-property.ui',
'late-property.ref.ui',
'letter-spacing.css',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]