From 662cc65bb9a483d79e12a6d7711ff72c60668725 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 13 Jun 2023 10:30:25 -0700 Subject: [PATCH] libsysprof-analyze: clean up descendant node tree on finalize --- src/libsysprof-analyze/sysprof-callgraph-private.h | 2 ++ src/libsysprof-analyze/sysprof-callgraph.c | 11 +++++------ src/libsysprof-analyze/sysprof-descendants-model.c | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/libsysprof-analyze/sysprof-callgraph-private.h b/src/libsysprof-analyze/sysprof-callgraph-private.h index 53a6da34..b83ba7f4 100644 --- a/src/libsysprof-analyze/sysprof-callgraph-private.h +++ b/src/libsysprof-analyze/sysprof-callgraph-private.h @@ -78,5 +78,7 @@ SysprofCallgraph *_sysprof_callgraph_new_finish (GAsyncResult GError **error); gpointer _sysprof_callgraph_get_symbol_augment (SysprofCallgraph *self, SysprofSymbol *symbol); +void _sysprof_callgraph_node_free (SysprofCallgraphNode *self, + gboolean free_self); G_END_DECLS diff --git a/src/libsysprof-analyze/sysprof-callgraph.c b/src/libsysprof-analyze/sysprof-callgraph.c index a111d9fe..db46db92 100644 --- a/src/libsysprof-analyze/sysprof-callgraph.c +++ b/src/libsysprof-analyze/sysprof-callgraph.c @@ -109,10 +109,9 @@ sysprof_callgraph_get_summary (SysprofCallgraph *self, return summary; } - -static void -sysprof_callgraph_node_free (SysprofCallgraphNode *node, - gboolean free_self) +void +_sysprof_callgraph_node_free (SysprofCallgraphNode *node, + gboolean free_self) { SysprofCallgraphNode *iter = node->children; @@ -120,7 +119,7 @@ sysprof_callgraph_node_free (SysprofCallgraphNode *node, { SysprofCallgraphNode *to_free = iter; iter = iter->next; - sysprof_callgraph_node_free (to_free, TRUE); + _sysprof_callgraph_node_free (to_free, TRUE); } if (free_self) @@ -156,7 +155,7 @@ sysprof_callgraph_finalize (GObject *object) g_clear_object (&self->document); g_clear_object (&self->traceables); - sysprof_callgraph_node_free (&self->root, FALSE); + _sysprof_callgraph_node_free (&self->root, FALSE); G_OBJECT_CLASS (sysprof_callgraph_parent_class)->finalize (object); } diff --git a/src/libsysprof-analyze/sysprof-descendants-model.c b/src/libsysprof-analyze/sysprof-descendants-model.c index d019418d..ac99cdc3 100644 --- a/src/libsysprof-analyze/sysprof-descendants-model.c +++ b/src/libsysprof-analyze/sysprof-descendants-model.c @@ -56,8 +56,6 @@ sysprof_descendants_model_get_item (GListModel *model, if (position != 0) return NULL; - g_warning ("TODO: Need to get proper ownership for node and proper summary"); - return _sysprof_callgraph_frame_new_for_node (self->callgraph, G_OBJECT (self), &self->root); } @@ -77,6 +75,8 @@ sysprof_descendants_model_finalize (GObject *object) { SysprofDescendantsModel *self = (SysprofDescendantsModel *)object; + _sysprof_callgraph_node_free (&self->root, FALSE); + g_clear_object (&self->callgraph); g_clear_object (&self->symbol);