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

In reply to Win32::GUI::Grid and CellData by ChrisR

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.