Re: TreeView update



Jonner: The GLIB CRITICAL posted i've really ever seen only under 2 conditions (and from ListStore's code i can't imagine any others): Either the model really doesn't post changes to the view, or threads are being used,  which can bring the view and model out of sync because of concurrent access. Also, "iter=m_refTreeModel->erase(iter)" seems right.


2008/6/5 Jonathon Jongsma <jonathon quotidian org>:
On Thu, 2008-06-05 at 15:15 +0800, Dinh Khac Thanh wrote:
> Hi all,
>
> I created a TreeView and a ListStore TreeModel in a Maemo application.
> The model is updated dynamically with data from an input file.
>
> Gtk::TreeView m_TreeView;
> Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
> To add row:
> Gtk::TreeModel::Row row = *(m_refTreeModel->append());
>
> To delete row:
> typedef Gtk::TreeModel::Children type_children;
> type_children children = m_refTreeModel->children();
> type_children::iterator iter = children.begin();
> and
> iter=m_refTreeModel->erase(iter); //in a while loop

I think the problem might be that you're doing this in a while loop.  If
you erase an iter, the iters that come after that become invalidated, so
when you move on to the next iter and try to delete it, it doesn't work
as expected.  If you want to remove all nodes, you could just use
Gtk::ListStore::clear().  Alternately, you might have better success if
you remove them from the end first.  Gtk::TreeRowReference might also be
helpful since it doesn't get invalidated when a different iter is
deleted.

--
Jonner

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



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