Hi Mark, thanks for all the help in this - I really appreciate it. My problem still stands, though. As most Wx applications, it's a big app, but I managed to get only the important bits to reproduce the bug. Here's a (complete) failing code:
-------------------8<------------------- use strict; use warnings; use Wx (':everything'); local $| = 1; warn "creating dialog"; my $dialog = Wx::Dialog->new( undef, -1, Wx::gettext("Padre Preferences"), Wx::wxDefaultPosition, Wx::wxDefaultSize, Wx::wxDEFAULT_DIALOG_STYLE | Wx::wxRESIZE_BORDER, ); $dialog->SetSizeHints( Wx::wxDefaultSize, Wx::wxDefaultSize ); warn "dialog created" if $dialog->isa('Wx::Dialog'); warn "creating treebook"; my $treebook = Wx::Treebook->new( $dialog, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, ); warn "treebook created" if $treebook->isa('Wx::Treebook'); warn "creating panel"; my $m_panel3 = Wx::Panel->new( $treebook, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, Wx::wxTAB_TRAVERSAL, ); warn "panel created" if $m_panel3->isa('Wx::Panel'); warn "creating fontpicker"; my $ctrl = Wx::FontPickerCtrl->new( $m_panel3, -1, Wx::wxNullFont, Wx::wxDefaultPosition, Wx::wxDefaultSize, Wx::wxFNTP_DEFAULT_STYLE, ); $ctrl->SetMaxPointSize(100); warn "fontpicker created" if $ctrl->isa('Wx::FontPickerCtrl'); my $value = ''; warn "setting up font"; my $font = Wx::Font->new(Wx::wxNullFont); warn "font created" if $font->isa('Wx::Font'); { warn "setting native"; local $@; eval { $font->SetNativeFontInfoUserDesc($value); }; if ($@) { warn "something's wrong: $@"; $font = Wx::Font->new(Wx::wxNullFont) } } warn "yes, it's still a font" if $font->isa('Wx::Font'); warn "setting selected font"; $ctrl->SetSelectedFont($font); warn "done!"; ------------------->8------------------- The output goes like this: $ perl test.pl creating dialog at test.pl line 7. dialog created at test.pl line 17. creating treebook at test.pl line 19. treebook created at test.pl line 26. creating panel at test.pl line 28. panel created at test.pl line 36. creating fontpicker at test.pl line 38. fontpicker created at test.pl line 48. setting up font at test.pl line 53. font created at test.pl line 55. setting native at test.pl line 57. yes, it's still a font at test.pl line 65. setting selected font at test.pl line 67. Segmentation fault I'm running wxPerl 0.99, wxWidgets 2.8.12 $ perl -V Summary of my perl5 (revision 5 version 14 subversion 0) configuration: Platform: osname=linux, osvers=2.6.35-28-generic, archname=x86_64-linux-thread-multi uname='linux bebop 2.6.35-28-generic #50-ubuntu smp fri mar 18 18:42:20 utc 2011 x86_64 gnulinux ' config_args='-de -Dprefix=/home/garu/perl5/perlbrew/perls/perl-5.14.0 -Dusethreads' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector' ccversion='', gccversion='4.4.5', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib /lib64 /usr/lib64 libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.12.1.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.12.1' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP PERL_PRESERVE_IVUV USE_64_BIT_ALL USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API Built under linux Compiled at May 14 2011 23:11:55 %ENV: PERLBREW_PATH="/home/garu/perl5/perlbrew/bin:/home/garu/perl5/perlbrew/perls/perl-5.14.0/bin" PERLBREW_PERL="perl-5.14.0" PERLBREW_ROOT="/home/garu/perl5/perlbrew" PERLBREW_VERSION="0.16" @INC: /home/garu/perl5/perlbrew/perls/perl-5.14.0/lib/site_perl/5.14.0/x86_64-linux-thread-multi /home/garu/perl5/perlbrew/perls/perl-5.14.0/lib/site_perl/5.14.0 /home/garu/perl5/perlbrew/perls/perl-5.14.0/lib/5.14.0/x86_64-linux-thread-multi /home/garu/perl5/perlbrew/perls/perl-5.14.0/lib/5.14.0 . Thanks! breno On Mon, May 16, 2011 at 9:25 AM, Mark Dootson <mark.doot...@znix.com> wrote: > Hi, > > You need to construct the Wx::FontpickerCtrl with the minimum arguments > > my $ctrl = Wx::FontPickerCtrl->new($someparentwindow, -1); > > Passing a font then seems to work OK? > > $ctrl->SetSelectedFont(wxNullFont); > > .. gets you no font selected > > $ctrl->SetSelectedFont (wxSWISS_FONT); > > .. gets you an appropriate default font. > > > If you still have difficulty, what are your versions of Wx, wxWidgets and > operating system? > > Regards > > Mark > > On 15/05/2011 14:01, breno wrote: >> >> 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 > >