libsysprof-analyze: use weak backpointers for child listmodel

This commit is contained in:
Christian Hergert
2023-06-20 11:26:10 -07:00
parent ab5c0c2bf7
commit 72d489f786

View File

@ -201,7 +201,7 @@ sysprof_callgraph_symbol_list_model_get_item (GListModel *model,
{
SysprofCallgraphSymbolListModel *self = (SysprofCallgraphSymbolListModel *)model;
if (self->symbols == NULL || position >= self->symbols->len)
if (self->symbols == NULL || position >= self->symbols->len || self->callgraph == NULL)
return NULL;
return _sysprof_callgraph_symbol_new (self->callgraph,
@ -227,7 +227,7 @@ sysprof_callgraph_symbol_list_model_dispose (GObject *object)
SysprofCallgraphSymbolListModel *self = (SysprofCallgraphSymbolListModel *)object;
g_clear_pointer (&self->symbols, g_ptr_array_unref);
g_clear_object (&self->callgraph);
g_clear_weak_pointer (&self->callgraph);
G_OBJECT_CLASS (sysprof_callgraph_symbol_parent_class)->dispose (object);
}
@ -254,7 +254,7 @@ _sysprof_callgraph_symbol_list_model_new (SysprofCallgraph *callgraph,
g_return_val_if_fail (SYSPROF_IS_CALLGRAPH (callgraph), NULL);
self = g_object_new (SYSPROF_TYPE_CALLGRAPH_SYMBOL_LIST_MODEL, NULL);
self->callgraph = g_object_ref (callgraph);
g_set_weak_pointer (&self->callgraph, callgraph);
if (symbols != NULL)
self->symbols = g_ptr_array_ref (symbols);