Hi,
It was a long time happening, but this is fixed in Wx 0.9912 recently
released to cpan.
Regards
Mark
On 01/12/2010 21:06, Eric J. Roode wrote:
I have a small test program that consistently crashes. I can't tell
if the crash is due to Wx or Perl, but I can trigger it on and off by
how I use a recent Perl feature.
Here is the program (it is also attached as "test.pl <http://test.pl>"):
#!perl
use Wx;
package MyApp;
use base 'Wx::App';
use MyList;
sub OnInit
{
my $self = shift;
my $frame = Wx::Frame->new(undef, -1, 'title');
my $panel = Wx::Panel->new($frame);
MyList->new(parent => $panel, pos => [10, 30], size => [500, 200]);
$frame->Show(1);
return 1;
}
# ---------------------------------
# Create the application object, and pass control to it.
package main;
my $app = MyApp->new;
$app->MainLoop;
"MyList" is a control derived from Wx::ListCtrl. Here is its code (also
attached as "MyList.pm"):
package MyList;
use Modern::Perl;
use Wx qw(:listctrl);
use base 'Wx::ListCtrl';
use Hash::Util::FieldHash;
Hash::Util::FieldHash::fieldhash # This is line 7
my %some_attribute;
sub new
{
my $class = shift;
my %parm = @_;
my $pos = $parm{pos} || [-1, 1];
my $size = $parm{size} || [-1, 1];
# Construct list control object
my $self = $class->SUPER::new($parm{parent}, -1, $pos, $size,
wxLC_REPORT | wxLC_HRULES |
wxLC_VRULES,
);
# Init member data
$some_attribute{$self} = 'sad';
# Initialize column
$self->InsertColumn(0, 'Zero');
return $self;
}
1;
This is a pretty straightforward, inside-out object. It doesn't do
anything but call Wx::ListCtrl's constructor with some fixed style
parameters, and inserts a column titled "Zero". It stores the value
"sad" in a member attribute that is a Fieldhash.
This program crashes consistently every time I run it. My system
is Windows 7 Professional 64-bit, 4gb RAM, dual-monitor, with Strawberry
Perl 5.12.1 (MSWin32-x86-multi-thread), with Wx.pm version 0.98, and
wxWidgets 2.8.10. The Windows Error Report is attached as "WEReport.txt".
Now the interesting part: Comment out line 7 (turning
%some_attribute from a field hash into a regular old hash), and the
program no longer crashes. I don't know if Hash::Util::FieldHash is
doing something bad, or if it's doing something that confuses Wx, or if
Wx is doing something bad.
--
Eric J. Roode