Errors removing rows from treestore



After much help, I've successfully implemented a TreeModel with a TreeModelFilter. However, I've noticed that if I expand a node, collapse it and expand it again, the contents are "doubled". That is, if the expanded row contained items A and B, on the second expansion the items in the row are now A B A B.

I tried using a model column flag to determine if the tree had been expanded once prior, but with no luck. Now I'm trying to simply remove the child rows in the on_row_collapsed() method like this:

void on_row_collapsed(const Gtk::TreeModel::iterator& iter,
                                     const Gtk::TreeModel::Path &path) {

Gtk::TreeModel::Row row = *iter;

const Gtk::TreeNodeChildren &nodeChildren = row.children();

Gtk::TreeModel::Children::iterator child = nodeChildren.begin();

while(child != nodeChildren.end()) {

   child = refTreeModel->erase(*child);  // this causes errors

}

}


The problem is that every time the while loop is executed I recieve this error:

Gtk-CRITICAL **: gtk_tree_store_remove: assertion `VALID_ITER (iter, tree_store)' failed

Any ideas as to what is the problem here? Or is there a better way to work around the doubled-up rows I'm running into?

Thanks,
Matt Bragano



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