Re: Help with TixGrid, segfault in Tix_LinkListNext
<[email protected]> Sun, 6 Dec 2009 18:33:42 -0800 (PST)
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <[email protected]> |
Hi Norbert
I tried running your example under perl on WinXP, but it crashes everytime the first click of the Update Grid button.
Changing this line:
$g->deleteRow(0, $curlines+1);
to this:
$g->deleteRow(1, $curlines);
lets it get a bit further, until it tries to return from update_grid the 3rd time. It was clearing the header row too.
Adding the line below at the top of the 'for my $p' loop lets it continue to pop letters off of @packs until the last visible one (nine remaining on winxp running with activestate's perl not counting the header lines- need to compare this to a linux perl) is removed and the program flow returns to MainLoop:
print $Packages{$p}{'cb'},"\n";
When it tries to return to MainLoop (or $g->update()) with less rows showing than the minimal amount it first displays, -height changes that, then it crashes.
A possible bug is that the deleteRow method doesn't change how many rows that the index method returns for a 'max' value. They're blank but still there so $curlines always gets the value of 26.
Changing the cell values from the Checkbox widgets to a text itemvalue lets it delete everything without crashing...
Tested on perl v5.10.1 - Binary build 1006 [291086] from activestate.
Phil Hartfield
phil681@yahoo / [email protected]
----- Original Message ----
From: Norbert Preining <[email protected]>
To: [email protected]
Sent: Sat, December 5, 2009 11:38:24 PM
Subject: Help with TixGrid, segfault in Tix_LinkListNext
Hi everyone,
I am having a problem with TixGrid. I want to embedd a check button
in the first column and at certain points update the grid (the list
of items to be shown).
I have code that actually works, but there is a problem with the selection.
As soon as I update the grid and scroll down the checkbuttons are
drawn incorrectly, namely some are selected that should not be.
Ok, that sounds rather complicted, I agree, so I tried to create a
minimal example, but that, even worse, made Tk segfault in
Tix_LinkListNext.
Here the code:
$^W = 1;
use strict;
use Tk;
use Tk::TixGrid;
my $mw = MainWindow->new();
my $g = $mw->TixGrid(-topmargin => 1);
my @packs = qw/a b c d e f g h i j k l m n o p q r s t u v w x y z/;
my %Packages;
$g->set(0,0, -itemtype => 'text', -text => "CB");
$g->set(1,0, -itemtype => 'text', -text => "Name");
my $i = 1;
for my $p (@packs) {
$Packages{$p}{'selected'} = $i%2;
$Packages{$p}{'cb'} = $g->Checkbutton(-variable => \$Packages{$p}{'selected'});
$g->set(0,$i, -itemtype => 'window', -widget => $Packages{$p}{'cb'});
$g->set(1,$i, -itemtype => 'text', -text => $p);
$i++;
}
$g->pack;
$mw->Button(-text => "Update Grid", -command => \&update_grid)->pack;
MainLoop;
sub update_grid {
my (undef, $curlines) = $g->index(0, 'max');
$g->deleteRow(1, $curlines+1);
pop @packs;
my $i = 1;
for my $p (@packs) {
$g->set(0,$i, -itemtype => 'window', -widget => $Packages{$p}{'cb'});
$g->set(1,$i, -itemtype => 'text', -text => $p);
$i++;
}
print "Foo\n";
}
Interestingly it crashes not always at the first time, but sometimes
at the n-th time I press the update grid button.
It is not the $g->set in the update_grid, because I always come around
the print "Foo\n"; but after that segfaults occur.
So I wonder if something is wrong with the above code, or some bug in
TixGrid I am hitting?
Thanks a lot for any suggestion
Norbert
------------------------------------------------------------------------
Norbert Preining preining@{jaist.ac.jp, logic.at, debian.org}
JAIST, Japan TU Wien, Austria Debian TeX Task Force
DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
------------------------------------------------------------------------
CLACKAVOID (n.)
Technical BBC term for a page of dialogue from Blake's Seven.
--- Douglas Adams, The Meaning of Liff
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk