Deleting rows from a model

Hi all. I've been looking at a long-standing bug in one of my libraries, triggered when I delete multiple rows from a tree model. After looking closer, my original bug appears to be caused by the fact that after going:

$model->remove( $iter );

 ... $iter is now pointing at the *next* row, without me having to go:

$model->iter_next( $iter );

So this initially seemed to be easy to solve - just don't call iter_next() if I've deleted a row. But ... I was previously exiting the loop, based on the return of $model->iter_next( $iter ). If there are no more rows, this call returns false. Since I'm not calling it for deleted rows, and since $iter is still 'set' in this case, how do I know if I'm at the end of the model?

Currently in this situation, my loop exits anyway, but due to:

( Gtk-CRITICAL **: 20:49:43.945: gtk_list_store_get_value: assertion 'iter_is_valid (iter, list_store)' failed

( Gtk-CRITICAL **: 20:49:55.529: gtk_list_store_get_value: assertion 'iter_is_valid (iter, list_store)' failed
*** unhandled exception in callback:
***   [gperl_sv_from_value] FIXME: unhandled type - 0 ((null) fundamental for (null))
***  ignoring at /usr/local/lib64/perl5/5.24.1/ line 546.

 ... which I guess is because, as the error says, $iter is not valid. Is there an iter_is_valid() method or something?

Thanks :)


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