On Aug 7, 2004, at 8:37 PM, Shane Mueller wrote:
> I'm getting a segfault when trying to create a label track (debian, wx
> 2.4, cvs audacity). A gdb trace is below, and the program crashes on
> the following line in LabelTrack.cpp.
> dc.GetTextExtent("Demo Text x^y", &textWidth, &textHeight);
> I think that that no valid font has yet been selected, and the UI to
> select the font is on the labeltrack, which won't load because of the
> segfault: a Catch-22 if I ever saw one. ResetFont gets called by the
> LabelTrack constructor, and only handles the case where facename is
> stored in the prefs, if not, msFont remains undefined.
Thanks for tracking this down. Apparently creating a wxFont with the
default constructor results in a valid font on some, but not all,
> The proper fix would presumably rely on setting wxFont based on
> conventions, but I'm not exactly sure how to do this. A quick fix that
> I'll check in to allow things to not crash is to change the default
> preference to some common font, like times:
> wxString facename = gPrefs->Read("/GUI/LabelFontFacename", "times");
> which should be recognized as a fontname on just about every computer.
> This of course is not a good solution and I hope somebody can figure
> a more robust fix soon.
I think that a simpler solution is simply to not call dc.SetFont if the
is not valid. In the past we were just using the default font for the
track and that was fine with me. So is the fix as simple as this?
We may also want to initialize msFont to wxNullFont, if wxNullFont.Ok()
Note: I specifically don't want "times" or any other string to go in
by default; I only want the preference set if the user explicitly
chooses a font.
BTW, I added this feature so that users could display label tracks in
an IPA font
(for phoenetic symbols).
> [Thread 32771 (LWP 24287) exited]
> Gdk-CRITICAL **: file gdkfont.c: line 335 (gdk_string_width): assertion
> `font != NULL' failed.
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 16384 (LWP 24266)]
> 0x403d87e0 in wxWindowDC::DoGetTextExtent () from /usr/lib/libwx_gtk-
> (gdb) bt
> #0 0x403d87e0 in wxWindowDC::DoGetTextExtent () from /usr/lib/
> #1 0x08088cc5 in LabelTrack::Draw (this=0x84a4310, dc=@0xbffff0c0,
> r=@0xbfffefb0, h=0, pps=86.1328125, sel0=0, sel1=0) at dc.h:362
> #2 0x080c83eb in TrackArtist::DrawLabelTrack (this=0x8484b70,
> track=0xffffffff, dc=@0xf7f, r=@0xf7f, viewInfo=0xf7f) at TrackArtist.
> #3 0x080c232d in TrackArtist::DrawTracks (this=0x8484b70,
> dc=@0xbffff0c0, r=@0xffffffff, clip=@0xbffff050, viewInfo=0x83a7540,
> drawEnvelope=false, drawSamples=false, drawSliders=false) at
> #4 0x080db905 in TrackPanel::DrawTracks (this=0x8463ad0,
> at TrackPanel.cpp:3527
> #5 0x080d4e69 in TrackPanel::OnPaint (this=0x8463ad0) at TrackPanel.
> #6 0x4045d667 in wxEvtHandler::SearchEventTable () from /usr/lib/
> This SF.Net email is sponsored by OSTG. Have you noticed the changes on
> Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
> one more big change to announce. We are now OSTG- Open Source
> Group. Come see the changes on the new OSTG site. http://www.ostg.com
> Audacity-devel mailing list