From 7039dc6102ffc5dcb4dcf7fb2c1f17018725af43 Mon Sep 17 00:00:00 2001 From: Kristian Rietveld Date: Sat, 9 Jul 2005 20:31:36 +0000 Subject: [PATCH] Fix #305737, patch from Tomislav Jonjic. This makes the 2005-07-09 Kristian Rietveld Fix #305737, patch from Tomislav Jonjic. This makes the gtk_tree_store_insert* family of functions emit row_has_child_toggled when needed (they didn't do that before). * gtk/gtktreestore.c (gtk_tree_store_insert): emit row_has_child_toggled when needed, (gtk_tree_store_insert_before): fix a possible memleak, emit row_has_child_toggled when needed, (gtk_tree_store_insert_after): ditto. --- ChangeLog | 12 ++++++++++ ChangeLog.pre-2-10 | 12 ++++++++++ ChangeLog.pre-2-8 | 12 ++++++++++ gtk/gtktreestore.c | 60 ++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 86 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1ab9436add..03f986e7a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-07-09 Kristian Rietveld + + Fix #305737, patch from Tomislav Jonjic. This makes the + gtk_tree_store_insert* family of functions emit row_has_child_toggled + when needed (they didn't do that before). + + * gtk/gtktreestore.c (gtk_tree_store_insert): emit + row_has_child_toggled when needed, + (gtk_tree_store_insert_before): fix a possible memleak, + emit row_has_child_toggled when needed, + (gtk_tree_store_insert_after): ditto. + 2005-07-09 Kristian Rietveld * gtk/gtktreeview.c (gtk_tree_view_real_expand_row): when diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 1ab9436add..03f986e7a5 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,15 @@ +2005-07-09 Kristian Rietveld + + Fix #305737, patch from Tomislav Jonjic. This makes the + gtk_tree_store_insert* family of functions emit row_has_child_toggled + when needed (they didn't do that before). + + * gtk/gtktreestore.c (gtk_tree_store_insert): emit + row_has_child_toggled when needed, + (gtk_tree_store_insert_before): fix a possible memleak, + emit row_has_child_toggled when needed, + (gtk_tree_store_insert_after): ditto. + 2005-07-09 Kristian Rietveld * gtk/gtktreeview.c (gtk_tree_view_real_expand_row): when diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 1ab9436add..03f986e7a5 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,15 @@ +2005-07-09 Kristian Rietveld + + Fix #305737, patch from Tomislav Jonjic. This makes the + gtk_tree_store_insert* family of functions emit row_has_child_toggled + when needed (they didn't do that before). + + * gtk/gtktreestore.c (gtk_tree_store_insert): emit + row_has_child_toggled when needed, + (gtk_tree_store_insert_before): fix a possible memleak, + emit row_has_child_toggled when needed, + (gtk_tree_store_insert_after): ditto. + 2005-07-09 Kristian Rietveld * gtk/gtktreeview.c (gtk_tree_view_real_expand_row): when diff --git a/gtk/gtktreestore.c b/gtk/gtktreestore.c index ed247bc767..f9e4cdd507 100644 --- a/gtk/gtktreestore.c +++ b/gtk/gtktreestore.c @@ -1140,8 +1140,10 @@ gtk_tree_store_insert (GtkTreeStore *tree_store, { GtkTreePath *path; GNode *parent_node; + GNode *new_node; g_return_if_fail (GTK_IS_TREE_STORE (tree_store)); + g_return_if_fail (iter != NULL); if (parent) g_return_if_fail (VALID_ITER (parent, tree_store)); @@ -1152,13 +1154,24 @@ gtk_tree_store_insert (GtkTreeStore *tree_store, tree_store->columns_dirty = TRUE; + new_node = g_node_new (NULL); + iter->stamp = tree_store->stamp; - iter->user_data = g_node_new (NULL); - g_node_insert (parent_node, position, G_NODE (iter->user_data)); + iter->user_data = new_node; + g_node_insert (parent_node, position, new_node); path = gtk_tree_store_get_path (GTK_TREE_MODEL (tree_store), iter); gtk_tree_model_row_inserted (GTK_TREE_MODEL (tree_store), path, iter); + if (parent_node != tree_store->root) + { + if (new_node->prev == NULL && new_node->next == NULL) + { + gtk_tree_path_up (path); + gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (tree_store), path, parent); + } + } + gtk_tree_path_free (path); validate_tree ((GtkTreeStore*)tree_store); @@ -1199,10 +1212,6 @@ gtk_tree_store_insert_before (GtkTreeStore *tree_store, if (sibling != NULL) g_return_if_fail (VALID_ITER (sibling, tree_store)); - tree_store->columns_dirty = TRUE; - - new_node = g_node_new (NULL); - if (parent == NULL && sibling == NULL) parent_node = tree_store->root; else if (parent == NULL) @@ -1215,6 +1224,10 @@ gtk_tree_store_insert_before (GtkTreeStore *tree_store, parent_node = G_NODE (parent->user_data); } + tree_store->columns_dirty = TRUE; + + new_node = g_node_new (NULL); + g_node_insert_before (parent_node, sibling ? G_NODE (sibling->user_data) : NULL, new_node); @@ -1225,6 +1238,20 @@ gtk_tree_store_insert_before (GtkTreeStore *tree_store, path = gtk_tree_store_get_path (GTK_TREE_MODEL (tree_store), iter); gtk_tree_model_row_inserted (GTK_TREE_MODEL (tree_store), path, iter); + if (parent_node != tree_store->root) + { + if (new_node->prev == NULL && new_node->next == NULL) + { + GtkTreeIter parent_iter; + + parent_iter.stamp = tree_store->stamp; + parent_iter.user_data = parent_node; + + gtk_tree_path_up (path); + gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (tree_store), path, &parent_iter); + } + } + gtk_tree_path_free (path); validate_tree ((GtkTreeStore*)tree_store); @@ -1265,10 +1292,6 @@ gtk_tree_store_insert_after (GtkTreeStore *tree_store, if (sibling != NULL) g_return_if_fail (VALID_ITER (sibling, tree_store)); - tree_store->columns_dirty = TRUE; - - new_node = g_node_new (NULL); - if (parent == NULL && sibling == NULL) parent_node = tree_store->root; else if (parent == NULL) @@ -1282,6 +1305,9 @@ gtk_tree_store_insert_after (GtkTreeStore *tree_store, parent_node = G_NODE (parent->user_data); } + tree_store->columns_dirty = TRUE; + + new_node = g_node_new (NULL); g_node_insert_after (parent_node, sibling ? G_NODE (sibling->user_data) : NULL, @@ -1293,6 +1319,20 @@ gtk_tree_store_insert_after (GtkTreeStore *tree_store, path = gtk_tree_store_get_path (GTK_TREE_MODEL (tree_store), iter); gtk_tree_model_row_inserted (GTK_TREE_MODEL (tree_store), path, iter); + if (parent_node != tree_store->root) + { + if (new_node->prev == NULL && new_node->next == NULL) + { + GtkTreeIter parent_iter; + + parent_iter.stamp = tree_store->stamp; + parent_iter.user_data = parent_node; + + gtk_tree_path_up (path); + gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (tree_store), path, &parent_iter); + } + } + gtk_tree_path_free (path); validate_tree ((GtkTreeStore*)tree_store);