gtktree: combination filter and using gtk_tree_model_foreach
- From: Rob Alblas <ralblas aimvalley nl>
- To: gtk-app-devel-list gnome org
- Subject: gtktree: combination filter and using gtk_tree_model_foreach
- Date: Wed, 24 May 2017 14:38:25 +0200 (CEST)
In a GtkTree I want to use a filter, and also extend the tree using gtk_tree_model_foreach. The combination
of the 2 gives problems.
In the function connected to gtk_tree_model_foreach I use the GtkTreeIter *iter argument, which gives an
error message:
Gtk-CRITICAL **: IA__gtk_tree_store_append: assertion `VALID_ITER (parent, tree_store)' failed
I define tree, filter etc. as follows:
stree = gtk_tree_store_new(1,G_TYPE_STRING);
ftree = GTK_TREE_MODEL_FILTER(gtk_tree_model_filter_new(GTK_TREE_MODEL(stree), NULL));
tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ftree));
model=gtk_tree_view_get_model(GTK_TREE_VIEW(tree));
...
(build a part of the tree)
...
gtk_tree_model_foreach(model,func,NULL);
In func:
gboolean func(GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data)
{
gtk_tree_model_get(model,iter, 0, &iname, -1);
...
gtk_tree_store_append(stree, &iter0, iter);
...
}
gtk_tree_store_append gives the mentioned error.
If I remove the filter, and define instead:
tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(stree));
then building using gtk_tree_model_foreach works fine.
How to solve this?
Attached an example showing the problem.
(Note: I am using gtk2.0, don't know if the same problem is with gtk3.)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]