Hi everyone!

The code below SegFaults when it tries to $ctrl->SetSelectedFont($font):

----------------------8<----------------------
use strict;
use warnings;
use Wx (':everything');

my $ctrl = Wx::FontPickerCtrl->new();
my $value = '';

my $font = Wx::Font->new(Wx::wxNullFont);
{
    local $@;
    eval { $font->SetNativeFontInfoUserDesc($value); };
    if ($@) {
        warn "something's wrong: $@";
        $font = Wx::Font->new(Wx::wxNullFont)
    }
}
$ctrl->SetSelectedFont($font);

print "yay";
---------------------->8----------------------

I think this might be related to
https://rt.cpan.org/Ticket/Display.html?id=66648 though I'm not sure
how to fix it, since I don't have control over the creation of the
$ctrl variable, only from "my $value = ''" onwards. Assuming this is
not a bug in Wx, what would be the best way to avoid the SegFault?
What I'm thinking is only calling $ctrl->SetSelectedFont($font) if
$value is defined, but shouldn't it work with Wx::wxNullFont ?

Thanks!

breno

Reply via email to