[gtk+] Don't access the parent level, there might not be one
- From: Kristian Rietveld <kristian src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+] Don't access the parent level, there might not be one
- Date: Tue, 8 Sep 2009 13:53:04 +0000 (UTC)
commit 16c5339ea8209ebc38cab417c9116d360eb9bac6
Author: Kristian Rietveld <kris gtk org>
Date: Tue Sep 8 15:51:10 2009 +0200
Don't access the parent level, there might not be one
Use the index instead, that can be -1. A unit test has been added as
well.
gtk/gtktreemodelfilter.c | 7 ++++---
gtk/tests/filtermodel.c | 26 ++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtktreemodelfilter.c b/gtk/gtktreemodelfilter.c
index 214bfe4..09a8d44 100644
--- a/gtk/gtktreemodelfilter.c
+++ b/gtk/gtktreemodelfilter.c
@@ -1720,11 +1720,12 @@ gtk_tree_model_filter_row_deleted (GtkTreeModel *c_model,
GtkTreeModelFilter *filter = GTK_TREE_MODEL_FILTER (data);
GtkTreePath *path;
GtkTreeIter iter;
- FilterElt *elt, *parent = NULL;
+ FilterElt *elt;
FilterLevel *level, *parent_level = NULL;
gboolean emit_child_toggled = FALSE;
gint offset;
gint i;
+ gint parent_elt_index = -1;
g_return_if_fail (c_path != NULL);
@@ -1887,7 +1888,7 @@ gtk_tree_model_filter_row_deleted (GtkTreeModel *c_model,
{
emit_child_toggled = TRUE;
parent_level = level->parent_level;
- parent = FILTER_LEVEL_PARENT_ELT (level);
+ parent_elt_index = level->parent_elt_index;
}
/* emit row_deleted */
@@ -1943,7 +1944,7 @@ gtk_tree_model_filter_row_deleted (GtkTreeModel *c_model,
iter.stamp = filter->priv->stamp;
iter.user_data = parent_level;
- iter.user_data2 = parent;
+ iter.user_data2 = &g_array_index (parent_level->array, FilterElt, parent_elt_index);
/* We set in_row_deleted to TRUE to avoid a level build triggered
* by row-has-child-toggled (parent model could call iter_has_child
diff --git a/gtk/tests/filtermodel.c b/gtk/tests/filtermodel.c
index 52e4afc..91420c4 100644
--- a/gtk/tests/filtermodel.c
+++ b/gtk/tests/filtermodel.c
@@ -2071,6 +2071,30 @@ specific_filter_add_child (void)
gtk_tree_store_set (store, &child, 0, "Hello", -1);
}
+static void
+specific_list_store_clear (void)
+{
+ int i;
+ GtkTreeIter iter;
+ GtkListStore *list;
+ GtkTreeModel *filter;
+ GtkWidget *view;
+
+ list = gtk_list_store_new (1, G_TYPE_INT);
+ gtk_list_store_insert_with_values (list, &iter, 0, 0, 1, -1);
+ gtk_list_store_insert_with_values (list, &iter, 1, 0, 2, -1);
+ gtk_list_store_insert_with_values (list, &iter, 2, 0, 3, -1);
+ gtk_list_store_insert_with_values (list, &iter, 3, 0, 4, -1);
+ gtk_list_store_insert_with_values (list, &iter, 4, 0, 5, -1);
+ gtk_list_store_insert_with_values (list, &iter, 5, 0, 6, -1);
+ gtk_list_store_insert_with_values (list, &iter, 6, 0, 7, -1);
+ gtk_list_store_insert_with_values (list, &iter, 7, 0, 8, -1);
+
+ filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (list), NULL);
+ view = gtk_tree_view_new_with_model (filter);
+
+ gtk_list_store_clear (list);
+}
static void
specific_bug_300089 (void)
@@ -2674,6 +2698,8 @@ main (int argc,
specific_root_has_child_filter);
g_test_add_func ("/FilterModel/specific/filter-add-child",
specific_filter_add_child);
+ g_test_add_func ("/FilterModel/specific/list-store-clear",
+ specific_list_store_clear);
g_test_add_func ("/FilterModel/specific/bug-300089",
specific_bug_300089);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]