[gtk/wip/baedert/for-master: 25/31] builderparser: Save finalizers in a GPtrArray
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 25/31] builderparser: Save finalizers in a GPtrArray
- Date: Tue, 12 Jan 2021 20:39:47 +0000 (UTC)
commit 67b36671cbb07238e7dcd939a94cd91809c430b7
Author: Timm Bäder <mail baedert org>
Date: Sat Jan 9 15:58:56 2021 +0100
builderparser: Save finalizers in a GPtrArray
We get up to 370 of these when starting the widget-factory.
gtk/gtkbuilderparser.c | 10 +++++-----
gtk/gtkbuilderprivate.h | 2 +-
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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]