[gtkmm] TreeView.set_cursor -- assertion failed



I have a problem with TreeView.set_cursor where the following two assertions
are not met if start_editing is set to true:

GTK_IS_TOOLBAR (container) || widget->parent == GTK_WIDGET (container)
GTK_IS_TREE_VIEW (tree_view)

But everything seems to be alright if start_editing is set to false. At least
I don't get any assertion failed messages then.

Below is a (hopefully) minimal example exhibiting the problem.

Ciao
Andreas



#include <gtkmm.h>

class MyWindow
    : public Gtk::Window
{
public:
    MyWindow();

protected:
    class MyModel
    	: public Gtk::TreeModel::ColumnRecord
    {
    public:
	MyModel(){ add(str); }
 	Gtk::TreeModelColumn<Glib::ustring> str;
    };

    MyModel model;
    Glib::RefPtr<Gtk::ListStore> ref_list_store;
    Gtk::TreeView tree_view;

    virtual void on_row_changed(
	const Gtk::TreeModel::Path &path,
	const Gtk::TreeModel::iterator &iter);
};

MyWindow::MyWindow()
{
    ref_list_store = Gtk::ListStore::create(model);
    tree_view.set_model(ref_list_store);
    tree_view.append_column_editable("foobar", model.str);
    ref_list_store->append();
    add(tree_view);
    show_all_children();

    ref_list_store->signal_row_changed().connect(
	sigc::mem_fun(*this, &MyWindow::on_row_changed));
}

void
MyWindow::on_row_changed(const Gtk::TreeModel::Path &path,
			 const Gtk::TreeModel::iterator &iter)
{
    ref_list_store->append();
    Gtk::TreeModel::iterator i = ref_list_store->children().end();
    i--;
    // assertions fail
    tree_view.set_cursor(Gtk::TreeModel::Path(i), *tree_view.get_column(0), true);
    // no assertions fail with this one
//    tree_view.set_cursor(Gtk::TreeModel::Path(i), *tree_view.get_column(0), false);
}

int
main(int argc, char *argv[])
{
    Gtk::Main kit(argc, argv);
    MyWindow foo;
    kit.run(foo);    
}



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