Bug#434646: libcurses-ui-perl: toogle destroys boolean value of Checkbox

Willi Mann willi at wm1.at
Wed Jul 25 14:30:30 UTC 2007


Package: libcurses-ui-perl
Version: 0.95-6
Severity: important

Function toogle in Checkbox.pm:

sub toggle()
{
	my $this = shift;
	$this->{-checked} = !$this->{-checked};
	$this->run_event('-onchange');
	$this->schedule_draw(1);
}

Unfortunatly, when the state was 1 and toogle was called, the state was
an empty string afterwards.

I changed this to 

sub toggle()
{
	my $this = shift;
	print STDERR "Before: ".$this->{-checked}."\n";
	$this->{-checked} = !$this->{-checked};
	print STDERR "middle: ".$this->{-checked}."\n";
	$this->run_event('-onchange');
	$this->schedule_draw(1);
	print STDERR "after: ".$this->{-checked}."\n";
}

and got 

Before: 1
middle:
after:

This is because:

$ perl -e 'print ((!0)."\n")';
1
$ perl -e 'print ((!1)."\n")';

$ perl -v

This is perl, v5.8.8 built for i486-linux-gnu-thread-multi
....



So, the line 

        $this->{-checked} = !$this->{-checked};

should be changed to

	$this->{-checked} = ( $this->{-checked} ? 0 : 1);


BTW: The hierarchy is wrong in Checkbox.pm, it lists Buttonbox instead
of Checkbox.




Versions of packages libcurses-ui-perl depends on:
ii  libcurses-perl                1.13-1     Curses interface for Perl
ii  libterm-readkey-perl          2.30-3     A perl module for simple terminal 
ii  perl                          5.8.8-7    Larry Wall's Practical Extraction 




More information about the pkg-perl-maintainers mailing list