Re: Remove Multiple Rows from Gtk2::ListStore



On 16.12.2009 20:24, Zettai Muri wrote:
So then I tried:

         my @paths = $selection->get_selected_rows;
         foreach my $p (@paths)
         {
             my $iter = $model->get_iter($p);
             $model->remove($iter);
         }

But when I select multiple rows and try to remove them it gives this error:
*** unhandled exception in callback:
***   variable not allowed to be undef where GtkTreeIter is wanted at line 654.

That likely happens because by removing rows you made one of the later paths refer to non-existant rows so that $model->get_iter($path) returns undef. One quick hack that might make this work is to iterate over the @paths in reverse order. But to be safe you should follow the doc's advice[1] of converting the paths to Gtk2::TreeRowReferences (which listen to changes in the model and adapt accordingly).

[1] <http://library.gnome.org/devel/gtk/stable/GtkTreeSelection.html#gtk-tree-selection-get-selected-rows>



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