Commit 16c5339e authored by Kristian Rietveld's avatar Kristian Rietveld

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.
parent 113d2180
......@@ -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
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment