Re: GtkListStore



On Wed, Apr 23, 2003 at 10:15:07AM +0100, martyn 2 russell bt com wrote:
 I am confused by this statement :
"Additionally, some models guarantee that an iterator is 
valid for as long as
the node it refers to is valid (most notably the GtkTreeStore and
GtkListStore)" (GtkTreeModel doc).


  Does it mean that I can store/save the interator in my 
application and use it
later to access the data ? ( Even if I delete/add rows ? )

I wouldn't recommend it.  What happens if you store it and the thing it
points to gets deleted? or moved? I *THINK* that at that point the iterator
becomes invalid, but even if it doesnt and you use it, you will not be
pointing at what you expect to be pointing at.

I agree with you though, the documentation is not very clear when it
introduces phrases like "... some models ...".  To me this sounds like they
mean, "...depending on how the model is implemented..." - I could be wrong.

I use GtkTreeIter* to have fast access to the lines in GtkTreeStore
and GtkTreeList.  I manage all the data in internal structs which
contain all the gui_data (in this case a pointer to GtkTreeIter). When
a entry gets inserted or deleted i call gui_entry_show() or
gui_entry_hide() which show/hide the entry in the List/Tree and update
the pointer to GtkTreeIter accordingly. If a node is moved GtkTreeIter
stay valid and still points to the correct node.

Like the documentation says: It depends on the TreeModel whether
GtkTreeIter stays valid but for the ListStore and TreeStore its true.

If you dont know the underlying model or are not sure whether you want
to use other models in the future i recommend using GtkTreeRowReference
instead.

Markus.



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