Skip to content

Commit

Permalink
Ensure we delete the correct iters
Browse files Browse the repository at this point in the history
Updates #700
  • Loading branch information
shawnlaffan committed Aug 10, 2018
1 parent 08bc93c commit 1fa52fa
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/Biodiverse/GUI/Tabs/Labels.pm
Original file line number Diff line number Diff line change
Expand Up @@ -538,25 +538,27 @@ sub remove_selected_labels_from_list {
$treeview1->set_model(undef);
$treeview2->set_model(undef);

# Convert paths to row references
# Convert paths to row references first
my @rowrefs;
foreach my $path (@paths) {
my $treerowreference = Gtk2::TreeRowReference->new ($model1, $path);
push @rowrefs, $treerowreference;
}


# now we delete them
# (cannot delete as we go as the paths and iters are affected by the deletions)
foreach my $rowref (@rowrefs) {
my $path = $rowref->get_path;
next if !defined $path;
my $iter = $global_model->get_iter($path);
$global_model->remove($iter);
my $iter = $model1->get_iter($path);
my $iter1 = $model1->convert_iter_to_child_iter($iter);
$global_model->remove($iter1);
}

$treeview1->set_model ($model1);
$treeview2->set_model ($model2);

# need to update the matrix if it is displayed
# but for some reason we aren't resetting all its rows and cols
$self->on_selected_matrix_changed (redraw => 1);

delete $self->{ignore_selection_change};
Expand Down

0 comments on commit 1fa52fa

Please sign in to comment.