libsysprof-analyze: clean up descendant node tree on finalize

This commit is contained in:
Christian Hergert
2023-06-13 10:30:25 -07:00
parent ee5ff400e7
commit 662cc65bb9
3 changed files with 9 additions and 8 deletions

View File

@ -78,5 +78,7 @@ SysprofCallgraph *_sysprof_callgraph_new_finish (GAsyncResult
GError **error); GError **error);
gpointer _sysprof_callgraph_get_symbol_augment (SysprofCallgraph *self, gpointer _sysprof_callgraph_get_symbol_augment (SysprofCallgraph *self,
SysprofSymbol *symbol); SysprofSymbol *symbol);
void _sysprof_callgraph_node_free (SysprofCallgraphNode *self,
gboolean free_self);
G_END_DECLS G_END_DECLS

View File

@ -109,10 +109,9 @@ sysprof_callgraph_get_summary (SysprofCallgraph *self,
return summary; return summary;
} }
void
static void _sysprof_callgraph_node_free (SysprofCallgraphNode *node,
sysprof_callgraph_node_free (SysprofCallgraphNode *node, gboolean free_self)
gboolean free_self)
{ {
SysprofCallgraphNode *iter = node->children; SysprofCallgraphNode *iter = node->children;
@ -120,7 +119,7 @@ sysprof_callgraph_node_free (SysprofCallgraphNode *node,
{ {
SysprofCallgraphNode *to_free = iter; SysprofCallgraphNode *to_free = iter;
iter = iter->next; iter = iter->next;
sysprof_callgraph_node_free (to_free, TRUE); _sysprof_callgraph_node_free (to_free, TRUE);
} }
if (free_self) if (free_self)
@ -156,7 +155,7 @@ sysprof_callgraph_finalize (GObject *object)
g_clear_object (&self->document); g_clear_object (&self->document);
g_clear_object (&self->traceables); 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); G_OBJECT_CLASS (sysprof_callgraph_parent_class)->finalize (object);
} }

View File

@ -56,8 +56,6 @@ sysprof_descendants_model_get_item (GListModel *model,
if (position != 0) if (position != 0)
return NULL; 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); 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; SysprofDescendantsModel *self = (SysprofDescendantsModel *)object;
_sysprof_callgraph_node_free (&self->root, FALSE);
g_clear_object (&self->callgraph); g_clear_object (&self->callgraph);
g_clear_object (&self->symbol); g_clear_object (&self->symbol);