The following code is incorrect, but it is causing a coredump.
My guess is that something isn't being checked for undef in
the C support code.

  my $cb = Wx::CheckBox->new(undef, .....);
  $cb->SetValue(1);       # We intermittently coredump here.

Note that the coredump is oddly intermittent.

Full testcase below.

Dave

---------------------------------------------------------------------------
Dave Ljung Madison          http://GetDave.com/                415 341-5555
------------ "Preferred over shiny round objects 2-to-1" ------------------


-- >8 snip here 8< -----------------------------------------------------
#!/usr/bin/perl -w -- 

use Wx 0.15 qw[:allclasses];
use strict;

my $COREDUMP = 1;       # Do we want to see the coredump?

package MyFrame;

use Wx qw[:everything];
use base qw(Wx::Frame);
use strict;

sub new {
        my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_;
        $parent = undef              unless defined $parent;
        $id     = -1                 unless defined $id;
        $title  = ""                 unless defined $title;
        $pos    = wxDefaultPosition  unless defined $pos;
        $size   = wxDefaultSize      unless defined $size;
        $name   = ""                 unless defined $name;

# begin wxGlade: MyFrame::new

        $style = wxDEFAULT_FRAME_STYLE 
                unless defined $style;

        $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, 
$name );
        $self->{someNotebook} = Wx::Notebook->new($self, -1, wxDefaultPosition, 
wxDefaultSize, 0);
        $self->{somePanel} = Wx::Panel->new($self->{someNotebook}, -1, 
wxDefaultPosition, wxDefaultSize, );
        $self->{someButton} = Wx::Button->new($self->{somePanel}, -1, "A 
button");

        $self->__set_properties();
        $self->__do_layout();

        return $self;
}

sub __set_properties {
        my $self = shift;

        $self->SetTitle("frame_1");
        $self->SetSize(Wx::Size->new(612, 392));
}

sub __do_layout {
        my $self = shift;

        $self->{someNotebook}->AddPage($self->{somePanel}, "Album");
        $self->SetAutoLayout(1);
        $self->Layout();
}

# end of class MyFrame

1;

package MyApp;

use base qw(Wx::App);
use strict;

sub OnInit {
        my( $self ) = shift;

        Wx::InitAllImageHandlers();

        my $frame_1 = MyFrame->new();

        $self->SetTopWindow($frame_1);
        $frame_1->Show(1);
        #$frame_1->SetFocus;    # So we get keys
        $frame_1->{someNotebook}->SetFocus;     # For some reason it needs to 
be this

        $frame_1->{app} = $self;

        return 1;
}
# end of class MyApp

package main;

my $app = MyApp->new();

# We screwup and use undef to create a new checkbox.. but then we coredump!
foreach my $tmp ( 1..1000 ) {
        print "tmp: $tmp\n";
        my $cb = Wx::CheckBox->new(undef, -1, "", MyFrame::wxDefaultPosition, 
MyFrame::wxDefaultSize, );
        $cb->SetValue(1) if $COREDUMP;  # This core dumps
}

$app->MainLoop();

Reply via email to