changeset 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 e7fb0df1caea
children 1a44d3ebacc1
files src/ChangeLog src/objects-x.c
diffstat 2 files changed, 20 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue May 09 05:15:15 2006 +0000
+++ b/src/ChangeLog	Tue May 09 10:40:09 2006 +0000
@@ -1,3 +1,10 @@
+2006-03-30  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* objects-x.c (x_initialize_font_instance):
+	Ensure that duplicative X font gets freed if we have an Xft font.
+	Remove some redundant debug output.
+	Comment on frequency of calls to this function.
+
 2006-05-08  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* EmacsShell-sub.c (RootGeometryManager):
--- 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
     {