Re: TreeView - First element



Hey, 
Look at that:

...
Gtk::TreeView ListTreeView;
Gtk::TreeModel::Row row;
Glib::RefPtr<Gtk::ListStore> ListTreeModel;
...


void fun::fun_move_down()
{
    if (!ListTreeView.get_hover_selection())

    {
        Glib::RefPtr<Gtk::TreeSelection> ref = ListTreeView.get_selection();
        Gtk::TreeModel::iterator iter = ref->get_selected();

        if (ListTreeModel->children().end() != iter)
            ListTreeModel->iter_swap(iter, iter++);
    }
}


When I select the last element on the list and perform this method I see in
console:
Gtk-CRITICAL **: gtk_list_store_swap: assertion `VALID_ITER (a, store)'
failed


if (ListTreeModel->children().end() != iter)
This should be false, but it isn't.



Juan A. Moreno wrote:
> 
> Probably your problem is here:
> 
>     ListTreeModel->iter_swap(iter, iter--)
> 
> 
> Because of the post-decrement what you are doing is the same as:
> ListTreeModel->iter_swap(iter, iter)
> and then iter - 1
> 
>     // But if iter is the first element from the list the code isn't work
> properly
> 
> You are doing "begin() != iter" so you are excluding the first element
> 
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 
> 

-- 
View this message in context: http://old.nabble.com/TreeView---First-element-tp26987764p26993645.html
Sent from the Gtkmm mailing list archive at Nabble.com.



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