Hi all,

I'm using GTK+ 1.2.7 and I've noticed that sometimes the font selection
dialog core dumps (segmentation violation.) The problem is that in my
system I have a couple of fonts with a "nil" foundry. The code doesn't
convert the "(nil)" string to "" in this case and the gdk_font_load()
function returns NULL, which is not checked from the caller -- the
gtk_font_selection_load_font() function, thus the core.

I compiled a small patch that fixes both problems (check for NULL and
convert the "(nil)" to "") and it seems to work for me...

Any comments?

+---------- BEGIN gtk-maglis-000309-0.patch ----------+

diff -Naur gtk+-1.2.7/gtk/gtkfontsel.c gtk+-1.2.7.new/gtk/gtkfontsel.c
--- gtk+-1.2.7/gtk/gtkfontsel.c Wed Feb 16 06:18:07 2000
+++ gtk+-1.2.7.new/gtk/gtkfontsel.c     Thu Mar  9 13:45:23 2000
@@ -1749,6 +1749,9 @@
   gchar *fontname, *label_text;
   XFontStruct *xfs;
   
+  /* sanity check */
+  g_return_val_if_fail (fontsel != NULL, FALSE);
+
   if (fontsel->font)
     gdk_font_unref (fontsel->font);
   fontsel->font = NULL;
@@ -1764,6 +1767,12 @@
       g_message("Loading: %s\n", fontname);
 #endif
       font = gdk_font_load (fontname);
+      if (!font)
+        {
+         gtk_label_set_text(GTK_LABEL(fontsel->message_label),
+                            _("The selected font is not available."));
+         return FALSE;
+       }
       xfs = GDK_FONT_XFONT(font);
       if (xfs->min_byte1 != 0 || xfs->max_byte1 != 0)
        {
@@ -3118,6 +3127,9 @@
   font = &fontsel_info->font_info[fontsel->font_index];
   family_str = font->family;
   foundry_str = fontsel_info->properties[FOUNDRY][font->foundry];
+  /* some fonts have a (nil) foundry */
+  if (strcmp (foundry_str, "(nil)") == 0)
+    foundry_str = "";
   
   for (prop = 0; prop < GTK_NUM_STYLE_PROPERTIES; prop++)
     {

+---------- END gtk-maglis-000309-0.patch ----------+

------------------------------------------------------------------------
Grigorios Magklis         e-mail: [EMAIL PROTECTED]
CS Dept, U of Rochester   phone : (716) 275-5605     fax: (716) 461-2018


-- 
To unsubscribe: mail -s unsubscribe [EMAIL PROTECTED] < /dev/null

Reply via email to