Re: [gtkmm] ListStore sorting and Gtk::TreeIter validity problems



Thanks again for your help, Chris!


On Sun, 2004-08-01 at 02:15, Chris Vine wrote:
> I have used similar code to yours and it has (and does) 
> work.

So do I, but unlike this time I never used the iterator taken from
get_selection() to re-access the actual TreeStore (in most cases, people
will probably only want to access the TreeRow).

I have now found out that the following code...

void GtkBookList::remove_selected(void)
{
  Gtk::TreeIter iter = sortstore->convert_iter_to_child_iter(
      get_selection()->get_selected());
  if (!iter)
    return;
  Book* book = iter->get_value(columns.book);
  printf("Book found: %s\n", book->get_title().c_str());
  store->erase(iter);
}

...does indeed remove the correct row, but then store->erase() also
generates error messages:

(test:10373): Gtk-CRITICAL **: file gtktreemodelsort.c: line 1055
(gtk_tree_model_sort_get_value): assertion `GTK_TREE_MODEL_SORT
(tree_model)->stamp == iter->stamp' failed

(test:10373): GLib-GObject-CRITICAL **: file gvalue.c: line 149
(g_value_unset): assertion `G_IS_VALUE (value)' failed

So does this mean that "get_selection()->get_selected()" returns a
sortstore iterator with an incorrect stamp set? Or maybe does
"sortstore->convert_iter_to_child_iter" not convert the stamp properly?

If I am not mistaken (which I may well enough be) then
"get_selection()->get_value()" is supposed to return an iterator
pointing to the ListStore rather then the TreeModelSort. (Can anyone
please confirm this?)

-Samuel
-- 
 ------------------------------------------------------
|      Samuel Abels       |   http://www.debain.org    |
| spam ad debain dod org  | knipknap ad jabber dod org |
 ------------------------------------------------------



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