Dear Monks!

It's been quite a while since I have asked something, but currently I am in the need of some wisdom again.

I have a Gtk/Perl application, which lists hostnames and when I click on a hostname, it opens a terminal with a SSH session to that host, and searches the root password in GPG encrypted file and saves it in the clipboard for about 60 seconds. That all works well.

Now, when I search the list (by simply typing in the application or using CTRL+F) and when it returns a selection made by the search, if I then use the arrows keys (up or down) to move along in the selection list, it crashes.

During the searches, I get the following warnings:

Gtk-CRITICAL **: gtk_tree_store_get_path: assertion 'iter->stamp == tr +ee_store->stamp' failed at 0PS_Terminal line 149.
(Line 149 is just the Gtk2->main)

If I use an arrow key, it crashes with Segmentation fault

The search is controlled by:

$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 throu +gh # 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->g +et_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);
The sub create_treestore looks like this:
sub create_treestore { my ($data) = @_; my ($tree_store) = Gtk2::TreeStore->new(qw/Glib::String Glib::Stri +ng 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; }

What am I doing wrong? Any idea / hint would be extremely helpful!

Thanks!

UPDATE:It only happens when the search input field is there. If I hit ESC after the search, the search input field disappears and then I can use the arrow keys to move along the selection list.

to ask a question is a moment of shame
to remain ignorant is a lifelong shame


In reply to Gtk2::TreeStore problem by insaniac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.