1
votes

I am trying to get the following code block below to work, the block of code is suppose to remove a row from a TreeView that has a TreeModelFilter, the code compiles and runs fine, however the TreeView does not reflect the row being removed.

// Remove an item
TreeIter iter;
TreeView.Selection.GetSelected (out iter);
TreeIter child_iter = Filter.ConvertChildIterToIter (iter);
ListStore.Remove(ref child_iter);

Edit:

Looking at error messages that occur on this block of code, which are:

Gtk-CRITICAL **: gtk_list_store_get_path: assertion 'iter->stamp == GTK_LIST_STORE (tree_model)->stamp' failed
Gtk-CRITICAL **: gtk_tree_model_filter_convert_child_iter_to_iter: assertion     'child_path != NULL' failed
Gtk-CRITICAL **: gtk_list_store_remove: assertion 'VALID_ITER (iter, list_store)' failed

It seems like the Apparently this means the iter is invalid, usally from a different model, but since I only have one treeviewmodel I think, even though I use a filter which I guess would make two.

1

1 Answers

0
votes

Always perform iterations on the unsorted model (based on TreeModel).

Filtering/sorting models can be chained and potentially reduce the set of visible data. They are only used for that purpose. Furthermore, the same model can be displayed in different tree views, with different filtering/sorting.