summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2021-01-09 15:58:56 +0100
committerTimm Bäder <mail@baedert.org>2021-01-17 04:39:26 +0100
commitcb41b96a9e4e0ab113395b9761b894d03bff5794 (patch)
tree4d721228d572951b3fc881186c08e4fc20736dfe
parent872b46a527e0ce6cd9fb44384be0d773310a280d (diff)
downloadgtk+-cb41b96a9e4e0ab113395b9761b894d03bff5794.tar.gz
builderparser: Save finalizers in a GPtrArray
We get up to 370 of these when starting the widget-factory.
-rw-r--r--gtk/gtkbuilderparser.c10
-rw-r--r--gtk/gtkbuilderprivate.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index 5008b4b7dd..b368d82cc5 100644
--- a/gtk/gtkbuilderparser.c
+++ b/gtk/gtkbuilderparser.c
@@ -1955,7 +1955,7 @@ end_element (GtkBuildableParseContext *context,
if (GTK_IS_BUILDABLE (object_info->object) &&
GTK_BUILDABLE_GET_IFACE (object_info->object)->parser_finished)
- data->finalizers = g_slist_prepend (data->finalizers, object_info->object);
+ g_ptr_array_add (data->finalizers, object_info->object);
if (object_info->signals)
{
@@ -2175,6 +2175,7 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
data.object_ids = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free, NULL);
data.stack = g_ptr_array_new ();
+ data.finalizers = g_ptr_array_new ();
if (requested_objs)
{
@@ -2214,10 +2215,9 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
}
/* Common parser_finished, for all created objects */
- data.finalizers = g_slist_reverse (data.finalizers);
- for (l = data.finalizers; l; l = l->next)
+ for (guint i = 0; i < data.finalizers->len; i++)
{
- GtkBuildable *buildable = (GtkBuildable*)l->data;
+ GtkBuildable *buildable = g_ptr_array_index (data.finalizers, i);
gtk_buildable_parser_finished (GTK_BUILDABLE (buildable), builder);
if (_gtk_builder_lookup_failed (builder, error))
@@ -2227,10 +2227,10 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
out:
g_slist_free_full (data.custom_finalizers, (GDestroyNotify)free_subparser);
- g_slist_free (data.finalizers);
g_free (data.domain);
g_hash_table_destroy (data.object_ids);
g_ptr_array_free (data.stack, TRUE);
+ g_ptr_array_free (data.finalizers, TRUE);
gtk_buildable_parse_context_free (&data.ctx);
/* restore the original domain */
diff --git a/gtk/gtkbuilderprivate.h b/gtk/gtkbuilderprivate.h
index 3b5568fa97..34a48dd454 100644
--- a/gtk/gtkbuilderprivate.h
+++ b/gtk/gtkbuilderprivate.h
@@ -179,7 +179,7 @@ typedef struct {
SubParser *subparser;
GtkBuildableParseContext ctx;
const char *filename;
- GSList *finalizers;
+ GPtrArray *finalizers;
GSList *custom_finalizers;
const char **requested_objects; /* NULL if all the objects are requested */