[gtkmm] multiple selections on TreeView



Hello!

I have a question about multiple selections on a TreeView under
gtkmm 2.0.1.

I must admit that I'm rather new to gtkmm. I started using it two weeks
ago. It's really easy to use (also if the docu is a little bit
incomplete for first time users).

Ok, but now my question. I have created a TreeView with a ListStore model
on a window together with a simple ADD and REMOVE button. Removing a
single selected line work fine. But I wanted to use the multiple selection
feature. After activating it I'm forced to use the selected_foreach()
method of the TreeSelection object (this is also described in the TreeView
tutorial):

void
foo::on_remove(void)
{
	treeView.get_selection()->selected_foreach(SigC::slot(*this,
				&foo::on_remove_selection));
}

void
foo::on_remove_selection(const Gtk::TreeModel::iterator &iter)
{
	reflistStore->erase(iter);
}

The problem is now that if I try to remove something at runtime I
get the following error message on stderr:

(main.exe:10569): Gtk-CRITICAL **: file gtktreeselection.c: line 491
(gtk_tree_selection_selected_foreach): assertion `has_next' failed.
There is a disparity between the internal view of the GtkTreeView,
and the GtkTreeModel.  This generally means that the model has changed
without letting the view know.  Any display from now on is likely to
be incorrect.


For me it looks like I can't call erase in on_remove_selection() as this
possible invalidates the iterator. If this is true is there any other way
to remove multiple selections? Or I'm tottaly wrong here?

Thanks for your help.


PS: This also happen if use the other overloaded selected_foreach()
method:

void
include_paths::on_remove_selection(const Gtk::TreeModel::Path &path)
{
	Gtk::TreeModel::iterator iter;

	iter = reflistStore->get_iter(path);
	if (iter)
		reflistStore->erase(iter);
}


Regards
   ...Frank

--
e-Mail: fnaumann freemint de




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