[gtk/gtk-4-6: 12/15] treelistmodel: Fix handling of collapsed nodes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-4-6: 12/15] treelistmodel: Fix handling of collapsed nodes
- Date: Mon, 12 Sep 2022 23:33:56 +0000 (UTC)
commit d21112a3ce1c2a8f8cfef81d9c77948eba7531e5
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Aug 24 08:20:33 2022 -0400
treelistmodel: Fix handling of collapsed nodes
When we collapse a node, we clear out the children,
but we were not disconnecting the signal handler on
the child listmodel, leading to bad outcomes when
that model is persistent and changing.
Fixes: #4595
gtk/gtktreelistmodel.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtktreelistmodel.c b/gtk/gtktreelistmodel.c
index 35f1fe3ab0..e5274da347 100644
--- a/gtk/gtktreelistmodel.c
+++ b/gtk/gtktreelistmodel.c
@@ -437,22 +437,28 @@ gtk_tree_list_model_items_changed_cb (GListModel *model,
static void gtk_tree_list_row_destroy (GtkTreeListRow *row);
static void
-gtk_tree_list_model_clear_node (gpointer data)
+gtk_tree_list_model_clear_node_children (TreeNode *node)
{
- TreeNode *node = data;
-
- if (node->row)
- gtk_tree_list_row_destroy (node->row);
-
if (node->model)
{
g_signal_handlers_disconnect_by_func (node->model,
gtk_tree_list_model_items_changed_cb,
node);
- g_object_unref (node->model);
+ g_clear_object (&node->model);
}
- if (node->children)
- gtk_rb_tree_unref (node->children);
+
+ g_clear_pointer (&node->children, gtk_rb_tree_unref);
+}
+
+static void
+gtk_tree_list_model_clear_node (gpointer data)
+{
+ TreeNode *node = data;
+
+ if (node->row)
+ gtk_tree_list_row_destroy (node->row);
+
+ gtk_tree_list_model_clear_node_children (node);
}
static void
@@ -547,8 +553,7 @@ gtk_tree_list_model_collapse_node (GtkTreeListModel *self,
n_items = tree_node_get_n_children (node);
- g_clear_pointer (&node->children, gtk_rb_tree_unref);
- g_clear_object (&node->model);
+ gtk_tree_list_model_clear_node_children (node);
tree_node_mark_dirty (node);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]