segfault related to views and fonts

Claude Marché <[email protected]> Thu, 07 Jan 2010 16:47:46 +0100
Newsgroups gmane.comp.lang.ocaml.lib.gtk
Message-ID <[email protected]>
Dear Lablgtk users,

The GUI of the Why tool, written with Lablgtk2, has a long-standing bug. 
The symptom is that the application crashes at start-up with a 
segmentation fault, but only under the KDE environment. A temporary but 
very unsatisfactory work-around is described here:

http://lists.gforge.inria.fr/pipermail/why-discuss/2009-March/000426.html

This bug has been also reported as a debian bug:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=440469

where this discussion contains interesting hints on the possible origin 
of the bug. In short, it seems that the seg fault is triggered in gtk, 
in a call to GText.view ().

First of all: any more ideas that could explain the bug is welcome!

Then, since it appears that the bug is related to character fonts, I'd 
like to change the way the Why GUI modifies the font sizes dynamically. 
In short, the font size is changed dynamically (with Ctrl+/Ctrl-) by a 
quite adhoc technique:

let font_family = ref "Monospace"

let font_size = ref 10

let modifiable_font_views = ref []

let change_font () =
   let f =
     Pango.Font.from_string
       (!font_family ^ " " ^ string_of_int !font_size)
   in
   List.iter (fun v -> v#modify_font f) !modifiable_font_views

where all text views are recorded in the reference 
[modifiable_font_views], and pressing say Ctrl+ increments [font_size] 
and calls [change_font].

I'd like to know if there are more natural ways the change the font 
size. In particular, I'd like to remove the dependency on an explicit 
font name like "Monospace", which might be a source of the bug.

Any ideas, suggestions, pointers are welcome!

- Claude