I am getting a very strange error, well, errors/warnings using
Win32::GUI::Grid. I have been attempting to use the
SetCellData and
GetCellData methods and am having quite a bit of trouble. I am using ActiveState Perl 5.6.1 build 638 on Win2000 in Komodo 3.0.1 with ActiveState's DevKit version 6. Win32 version is .22, Win32::GUI version is 1.0, and I've tried Win32::Gui::Grid versions .06 and .07
Problems:
1) I set the data for each cell using
SetCellData but the data returned for any cell by
GetCellData is that of the last cell I set
2) The above only happens one time. Each subsequent call time throws a warning and does not return the value.
3) Warning while running from Komodo:
Attempt to free unreferenced scalar at C:/Program Files/ActiveState Komodo 3.0/dbgp/perllib/perl5db.pl line 3645.
4) Warning when compiled without hiding the console:
Attempt to free unreferenced scalar at Perl-5.pl line 21.
5) Error when compiled hiding the console:
Bad file descriptor
The strangest part to me is that the warning is different depending on how it is being run. I have created a lot of problematic code in my time but not anything that reacts like this.
Also, I get:
Argument "Win32::GUI" isn't numeric in subroutine entry at Perl-5.pl line 29. This one only happens the first time the message box is displayed and I'm not really worried about it at this point.
I'm completely lost and thought this must be a bug but then again, who am I to say it is a bug. My guess is that I am the bug in this case but I just can't figure out what I'm doing wrong. I found this in perldiag but have no idea what it means:
(W internal) Perl went to decrement the reference count of a scalar to see if it would go to 0, and discovered that it had already gone to 0 earlier, and should have been freed, and in fact, probably was freed. This could indicate that SvREFCNT_dec() was called too many times, or that SvREFCNT_inc() was called too few times, or that the SV was mortalized when it shouldn't have been, or that memory has been corrupted
Here is a small sample of code that reproduces. the problems.
#!/usr/bin/perl -w
use strict;
use Win32::GUI;
use Win32::GUI::Grid;
my $main = Win32::GUI::Window->new(-name=>'main',-text=>'grid test',-w
+idth=>400,-height=>200,-dialogui=>1);
$main->AddGrid(-name=>'grid',-pos=>[30,40],-rows=>3,-columns=>3,-fixed
+rows=>1,-fixedcolumns=>0,-editable=>0,-size=> [350,75],-addstyle=>WS_
+VSCROLL|WS_TABSTOP);
for my $col(0..2)
{
$main->grid->SetCellText(0, $col, "H$col");
}
for my $row(1..2)
{
for my $col(0..2)
{
$main->grid->SetCellText($row, $col, "$row:$col");
$main->grid->SetCellData($row, $col, "$row $col") or die "Coul
+d not set celldata: $!\n";
}
}
$main->Show();
Win32::GUI::Dialog();
exit;
sub grid_Click
{
my ($row,$col) = @_;
my $celldata = $main->grid->GetCellData($row, $col) or die "Error:
+ $!\n";
my $ret = Win32::GUI->MessageBox("ROW: $row COL: $col (CELLDATA: $
+celldata)");
return 1;
}
Any help in this would greatly appreciated.
Thanks,
Chris