GtkTreeModelFilter and virtual-root


Should the virtual-root property found in GtkTreeModelFilter stay valid
all the time relative to parent model. I am having a problem that virtual-root
do not point a valid child node after nodes are added to child model in
a certain way. See the attached tester. Is this a bug or am I doing something

I need this because I cannot just use gtk_tree_model_get for the root node
(NULL iterators/paths are not allowed).


#include <gtk/gtk.h>

int main(int argc, char *argv[])
	GtkTreeModel *filter;
	GtkTreeStore *store;
	GtkTreeIter iter, child_iter;
	GtkTreePath *path;
	gboolean success;

	gtk_init(&argc, &argv);
	store = gtk_tree_store_new(1, G_TYPE_INT);

	gtk_tree_store_append(store, &iter, NULL);
	gtk_tree_store_set(store, &iter, 0, 0, -1);	
	gtk_tree_store_append(store, &iter, NULL);
	gtk_tree_store_set(store, &iter, 0, 1, -1);
	gtk_tree_store_append(store, &child_iter, &iter);
	gtk_tree_store_set(store, &child_iter, 0, 3, -1);	
	path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &child_iter);
	g_assert(path != NULL);
	filter = gtk_tree_model_filter_new(GTK_TREE_MODEL(store), path);
	gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
	/* Virtual root changes here */
	gtk_tree_store_append(store, &child_iter, &iter);			
	g_object_get(filter, "virtual-root", &path, NULL);	
	/* We should get an iterator pointing to number 3, but
		 virtual root do not point to any node. */
	success = gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path);
	g_assert(success); /* This fails */
	return 0;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]