G'day Stephen. I recently got annoyed enough to track down a problem
with the XFT branch that was causing my X server to lock up for minutes
when I exited XEmacs, as well as causing a gradual slowdown as I used
it.
Basically, the Xft integration to lwlib was leaking an XftDraw context
from menu drawing, resulting in a pixmap leak in the server. Once you
have 90,000 Pixmaps, things get a little slow.
The server lockup is a suboptimal X.org bug when freeing all 90,000
Pixmaps at one time, apparently. The don't seem to handle that at all
well.:)
Anyway, the attached patch fixes the leak by freeing the XftDraw context
appropriately. It also cleans up some XLFD loading, and adds a more
sane fallback path to the font loading.
One possible controversial part: the original code tried to enforce that
an XLFD font was not scaled, while the new version just doesn't care.
I think that is a better behavior, since if someone really wants a
scaled font we should oblige them.
Daniel
? build.sh
? lib-src/insert-data-in-exec
? src/dump-size
? src/xemacs.def
? src/xemacs.def.in
Index: lwlib/lwlib-fonts.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lwlib/Attic/lwlib-fonts.c,v
retrieving revision 1.1.2.1
diff -u -u -r1.1.2.1 lwlib-fonts.c
--- lwlib/lwlib-fonts.c 2004/11/25 12:44:05 1.1.2.1
+++ lwlib/lwlib-fonts.c 2005/09/02 07:39:45
@@ -26,6 +26,8 @@
/* Synched up with: Not in GNU Emacs. */
#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
#include "lwlib-fonts.h"
#if 0
@@ -62,29 +64,24 @@
pos++;
}
+ /* #### hard-coding DefaultScreen is evil! */
if (count < 14 && !(count >= 5 && index (name, '*')))
- /* #### hard-coding DefaultScreen is evil! */
res = XftFontOpenName (dpy, DefaultScreen (dpy), name);
else
- {
- FcPattern *pat = FcPatternCreate ();
- /* This is the magic pattern to open core fonts ... */
- /* Dudes, I love Xft!!! */
- FcPatternAddString (pat, XFT_XLFD, (FcChar8 *) name);
- /* #### Is this core fonts, or is this using the core protocol when
- Xrender is unavailable? */
- FcPatternAddBool (pat, XFT_CORE, True);
- FcPatternAddBool (pat, FC_SCALABLE, False);
- res = XftFontOpenPattern (dpy, pat);
- }
+ res = XftFontOpenXlfd (dpy, DefaultScreen (dpy), name);
+
+ /* Try for a generic monospace font */
+ if (!res)
+ res = XftFontOpenName (dpy, DefaultScreen (dpy), "monospace");
+ /* Try for anything we can get */
if (!res)
- /* this is our last try ... */
res = XftFontOpenName (dpy, DefaultScreen (dpy), "");
if (!res)
{
/* #### This is Just So Wrong ... ! */
/* sorry folks ... */
+ fprintf (stderr, "Unable to find any usable XFT font, even the defaults!\n");
abort ();
return 0;
}
Index: lwlib/xlwmenu.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lwlib/xlwmenu.c,v
retrieving revision 1.37.2.2
diff -u -u -r1.37.2.2 xlwmenu.c
--- lwlib/xlwmenu.c 2004/12/10 06:43:25 1.37.2.2
+++ lwlib/xlwmenu.c 2005/09/02 07:39:47
@@ -894,6 +894,7 @@
XftTextExtents8 (display, renderFont, &string[start], end - start,
&glyphinfo);
+ XftDrawDestroy (xftDraw);
return glyphinfo.xOff;
}
#else