Gtk-CRITICAL **: gtk_tree_store_get_path: assertion 'iter->stamp == tree_store->stamp' failed at 0PS_Terminal line 149.
####
$tree_view->set_search_equal_func(sub {
# reset to the main tree store, containing all the hosts
$tree_view->set_model($tree_store);
my ($_tree_store, $path, $pattern, $iter) = @_;
return unless length($pattern) > 2;
my %results;
$_tree_store->foreach(sub {
my ($model, $path, $iter) = @_ ;
my $host = $model->get($iter, 0);
my $ip = $model->get($iter, 1);
if($host =~ /$pattern/){
# print "Found $host for $pattern\n";
$results{$host} = $ip;
}
# return 0, so that the function always iterates through
# the entire tree store
return 0
});
# build the new tree store and display in the tree view
if(scalar keys %results > 0){
my $new_treestore = create_treestore(\%results);
$tree_view->set_model($new_treestore);
# $tree_view->set_cursor(0);
$tree_view->set_search_column(0);
# my $iter = $new_treestore->get_first_iter();
my $path = $new_treestore->get_path( $new_treestore->get_iter_first() );
$tree_view->set_cursor($path);
undef $path;
#get the Gtk2::TreeSelection of $tree_view
my $treeselection = $tree_view->get_selection;
#set its initial mode
$treeselection->set_mode('single');
}
}, undef);
####
sub create_treestore {
my ($data) = @_;
my ($tree_store) = Gtk2::TreeStore->new(qw/Glib::String Glib::String Glib::String/);
my $count = 0;
foreach my $host (sort keys %{$data}){
my $iter_child = $tree_store->append(undef);
my ($dc) = ($host =~ /^(.+?)-/);
my $ip = lookup_host_in_hostlistdb($host);
my $background = get_background($dc);
$tree_store->set($iter_child, 0, $host,
1, $ip,
2, ($count++ % 2 ? $background->[1]:$background->[0]),
);
}
return $tree_store;
}