Stuart Hughes <[EMAIL PROTECTED]> writes:

> I'm reading data from a file into a gtk.ListStore.  Sometimes the
> number of rows in the file can reduce, so I want to be able to refresh
> the valid rows, and delete the remaining invalid rows so they don't
> show up.
> 
> After refreshing the valid rows (the data runs out), I have an iter
> that points at the first row that I need to remove.
>
> So I tried:
> 
> while iter:
>      self.lstore.remove(iter)
>      iter = self.lstore.iter_next(iter)
> 
> This mostly works, but sometimes I get:
> 
>   GtkWarning: file gtkliststore.c: line 590
> (gtk_list_store_iter_next): assertion `GTK_LIST_STORE
> (tree_model)->stamp == iter->stamp' failed
>    iter = self.lstore.iter_next(iter)

This looks close.  Once you remove(iter), iter is no longer valid so
you shouldn't use it any longer.  In particular the iter_next(iter)
following remove(iter) is an error.  GTK+ might not catch this every
time, but sometimes you would probably get an assertion failure like
the one you see.

I think you can make this work if you get the next iter and save it
before the remove() like this

    while iter:
        next = self.lststore.iter_next(iter)
        self.lstsore.remove(iter)
        iter = next
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to