diff src/objects-x.c @ 3389:77b0b03fbc47

[xemacs-hg @ 2006-05-09 10:40:07 by stephent] Avoid leaking FontStructs. <87lktblbyt.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Tue, 09 May 2006 10:40:09 +0000
parents 316fddbf58e2
children ac11131c6de9
line wrap: on
line diff
--- a/src/objects-x.c	Tue May 09 05:15:15 2006 +0000
+++ b/src/objects-x.c	Tue May 09 10:40:09 2006 +0000
@@ -309,6 +309,12 @@
       return 0;
     }
 
+  if (rf && fs)
+    {
+      XFreeFont (dpy, fs);
+      fs = NULL;		/* we don' need no steenkin' X font */
+    }
+
   if (fs && !fs->max_bounds.width)
     {
       /* yes, this has been known to happen. */
@@ -316,8 +322,7 @@
       fs = NULL;
       maybe_signal_error (Qgui_error, "X font is too small", f->name, Qfont,
 			  errb);
-      if (!rf)
-	return 0;
+      return 0;
     }
 
   /* Now that we're sure that we will succeed, we can allocate data without
@@ -353,11 +358,12 @@
       f->height = rf->height;
       f->proportional_p = 1; 	/* we can't recognize monospaced fonts! */
 
-      DEBUG_XFT4 (0, "initialized metrics ascent %d descent %d width %d height %d\n",
-		    f->ascent, f->descent, f->width, f->height);
-      /* we also output on initialization of any font below */
-      DEBUG_XFT1 (2, "initialized Xft font %s\n", XSTRING_DATA(f->name));
-      fs = NULL;		/* we don' need no steenkin' X font */
+      /* #### This message appears wa-a-ay too often!
+	 We probably need to cache truenames or something?
+	 Even if Xft does it for us, we cons too many font instances. */
+      DEBUG_XFT4 (0,
+	"initialized metrics ascent %d descent %d width %d height %d\n",
+	f->ascent, f->descent, f->width, f->height);
     } 
   else
     {