From: Benjamin Otte Date: Wed, 26 Apr 2023 21:40:56 +0000 (+0200) Subject: treelistmodel: Delay notifies from TreeListRow X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~367^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3c76f3fb58aeb717b127ebf170819bc6b6aac3da;p=gtk4.git treelistmodel: Delay notifies from TreeListRow Don't notify during destruction, notify afterwards. This way we don't call into user code from a half-destructed node. Note that this changes the order in which those notifies happen when collapsing a large tree: From parent node before child nodes to child nodes before parent node. No actual use case for this, just thought it would be safer. --- diff --git a/gtk/gtktreelistmodel.c b/gtk/gtktreelistmodel.c index 81b4319c15..a4f0fa1d4b 100644 --- a/gtk/gtktreelistmodel.c +++ b/gtk/gtktreelistmodel.c @@ -415,10 +415,16 @@ gtk_tree_list_model_clear_node (gpointer data) TreeNode *node = data; if (node->row) - gtk_tree_list_row_destroy (node->row); + { + g_object_freeze_notify (G_OBJECT (node->row)); + gtk_tree_list_row_destroy (node->row); + } gtk_tree_list_model_clear_node_children (node); + if (node->row) + g_object_thaw_notify (G_OBJECT (node->row)); + g_clear_object (&node->item); } @@ -955,16 +961,12 @@ G_DEFINE_TYPE (GtkTreeListRow, gtk_tree_list_row, G_TYPE_OBJECT) static void gtk_tree_list_row_destroy (GtkTreeListRow *self) { - g_object_freeze_notify (G_OBJECT (self)); - self->node = NULL; /* FIXME: We could check some properties to avoid excess notifies */ g_object_notify_by_pspec (G_OBJECT (self), row_properties[ROW_PROP_DEPTH]); g_object_notify_by_pspec (G_OBJECT (self), row_properties[ROW_PROP_EXPANDABLE]); g_object_notify_by_pspec (G_OBJECT (self), row_properties[ROW_PROP_EXPANDED]); - - g_object_thaw_notify (G_OBJECT (self)); } static void