From baf21fbfa2cfacad32b1bf593ce81927f2ba7836 Mon Sep 17 00:00:00 2001 From: Kristian Rietveld Date: Fri, 15 Feb 2002 18:38:02 +0000 Subject: [PATCH] new function (gtk_tree_store_clear): traverse the tree, so we emit Fri Feb 15 19:38:00 2002 Kristian Rietveld * gtk/gtktreestore.c (gtk_tree_store_clear_traverse): new function (gtk_tree_store_clear): traverse the tree, so we emit row_deleted for every node. This way we don't have confused row refs crashing the application. (#70631) --- ChangeLog | 7 +++++++ ChangeLog.pre-2-0 | 7 +++++++ ChangeLog.pre-2-10 | 7 +++++++ ChangeLog.pre-2-2 | 7 +++++++ ChangeLog.pre-2-4 | 7 +++++++ ChangeLog.pre-2-6 | 7 +++++++ ChangeLog.pre-2-8 | 7 +++++++ gtk/gtktreestore.c | 50 ++++++++++++++++++++++++++++++++++++++-------- 8 files changed, 91 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0fd6600ae6..887b263ec9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Feb 15 19:38:00 2002 Kristian Rietveld + + * gtk/gtktreestore.c (gtk_tree_store_clear_traverse): new function + (gtk_tree_store_clear): traverse the tree, so we emit row_deleted + for every node. This way we don't have confused row refs crashing the + application. (#70631) + 2002-02-14 Richard Hult * gtk/gtkpaned.c (gtk_paned_enter): Only queue a draw on the diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 0fd6600ae6..887b263ec9 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,10 @@ +Fri Feb 15 19:38:00 2002 Kristian Rietveld + + * gtk/gtktreestore.c (gtk_tree_store_clear_traverse): new function + (gtk_tree_store_clear): traverse the tree, so we emit row_deleted + for every node. This way we don't have confused row refs crashing the + application. (#70631) + 2002-02-14 Richard Hult * gtk/gtkpaned.c (gtk_paned_enter): Only queue a draw on the diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 0fd6600ae6..887b263ec9 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +Fri Feb 15 19:38:00 2002 Kristian Rietveld + + * gtk/gtktreestore.c (gtk_tree_store_clear_traverse): new function + (gtk_tree_store_clear): traverse the tree, so we emit row_deleted + for every node. This way we don't have confused row refs crashing the + application. (#70631) + 2002-02-14 Richard Hult * gtk/gtkpaned.c (gtk_paned_enter): Only queue a draw on the diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 0fd6600ae6..887b263ec9 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,10 @@ +Fri Feb 15 19:38:00 2002 Kristian Rietveld + + * gtk/gtktreestore.c (gtk_tree_store_clear_traverse): new function + (gtk_tree_store_clear): traverse the tree, so we emit row_deleted + for every node. This way we don't have confused row refs crashing the + application. (#70631) + 2002-02-14 Richard Hult * gtk/gtkpaned.c (gtk_paned_enter): Only queue a draw on the diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 0fd6600ae6..887b263ec9 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +Fri Feb 15 19:38:00 2002 Kristian Rietveld + + * gtk/gtktreestore.c (gtk_tree_store_clear_traverse): new function + (gtk_tree_store_clear): traverse the tree, so we emit row_deleted + for every node. This way we don't have confused row refs crashing the + application. (#70631) + 2002-02-14 Richard Hult * gtk/gtkpaned.c (gtk_paned_enter): Only queue a draw on the diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 0fd6600ae6..887b263ec9 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +Fri Feb 15 19:38:00 2002 Kristian Rietveld + + * gtk/gtktreestore.c (gtk_tree_store_clear_traverse): new function + (gtk_tree_store_clear): traverse the tree, so we emit row_deleted + for every node. This way we don't have confused row refs crashing the + application. (#70631) + 2002-02-14 Richard Hult * gtk/gtkpaned.c (gtk_paned_enter): Only queue a draw on the diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 0fd6600ae6..887b263ec9 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +Fri Feb 15 19:38:00 2002 Kristian Rietveld + + * gtk/gtktreestore.c (gtk_tree_store_clear_traverse): new function + (gtk_tree_store_clear): traverse the tree, so we emit row_deleted + for every node. This way we don't have confused row refs crashing the + application. (#70631) + 2002-02-14 Richard Hult * gtk/gtkpaned.c (gtk_paned_enter): Only queue a draw on the diff --git a/gtk/gtktreestore.c b/gtk/gtktreestore.c index ebe1e6a8dc..c4497be735 100644 --- a/gtk/gtktreestore.c +++ b/gtk/gtktreestore.c @@ -1423,6 +1423,47 @@ gtk_tree_store_iter_depth (GtkTreeStore *tree_store, return g_node_depth (G_NODE (iter->user_data)) - 2; } +/* simple ripoff from g_node_traverse_post_order */ +static gboolean +gtk_tree_store_clear_traverse (GNode *node, + GtkTreeStore *store) +{ + GtkTreeIter iter; + + if (node->children) + { + GNode *child; + + child = node->children; + while (child) + { + register GNode *current; + + current = child; + child = current->next; + if (gtk_tree_store_clear_traverse (current, store)) + return TRUE; + } + + if (node->parent) + { + iter.stamp = store->stamp; + iter.user_data = node; + + gtk_tree_store_remove (store, &iter); + } + } + else if (node->parent) + { + iter.stamp = store->stamp; + iter.user_data = node; + + gtk_tree_store_remove (store, &iter); + } + + return FALSE; +} + /** * gtk_tree_store_clear: * @tree_store: a #GtkTreeStore @@ -1432,16 +1473,9 @@ gtk_tree_store_iter_depth (GtkTreeStore *tree_store, void gtk_tree_store_clear (GtkTreeStore *tree_store) { - GtkTreeIter iter; - g_return_if_fail (GTK_IS_TREE_STORE (tree_store)); - while (G_NODE (tree_store->root)->children) - { - iter.stamp = tree_store->stamp; - iter.user_data = G_NODE (tree_store->root)->children; - gtk_tree_store_remove (tree_store, &iter); - } + gtk_tree_store_clear_traverse (tree_store->root, tree_store); } /* DND */