[X11DRV] Fix once and for all bad font loading...

Lionel Ulmer lionel.ulmer at free.fr
Sun Sep 14 12:29:46 CDT 2003


Hopefully what I say in the topic is correct :-)

Changelog:
 - check X11 errors on each XLoadQueryFont calls

-- 
		 Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
Index: graphics/x11drv/xfont.c
===================================================================
RCS file: /home/wine/wine/graphics/x11drv/xfont.c,v
retrieving revision 1.118
diff -u -r1.118 xfont.c
--- graphics/x11drv/xfont.c	20 Aug 2003 18:22:31 -0000	1.118
+++ graphics/x11drv/xfont.c	14 Sep 2003 16:43:06 -0000
@@ -2027,6 +2027,21 @@
     return 1;
 }
 
+/* XLoadQueryFont has the bad habit of crashing when loading a bad font... */
+static XFontStruct *safe_TSXLoadQueryFont(Display *display, char *name)
+{
+    XFontStruct *ret;
+    
+    wine_tsx11_lock();
+    X11DRV_expect_error(display, XLoadQueryFont_ErrorHandler, NULL);
+    ret = XLoadQueryFont(display, name);
+    if (X11DRV_check_error()) ret = NULL;
+    wine_tsx11_unlock();
+
+    return ret;
+}
+
+
 static int XFONT_BuildMetrics(char** x_pattern, int res, unsigned x_checksum, int x_count)
 {
     int		  i;
@@ -2129,12 +2144,7 @@
 	else lpstr = x_pattern[i];
 
 	/* X11 may return an error on some bad fonts... So be prepared to handle these. */
-	wine_tsx11_lock();
-	X11DRV_expect_error(gdi_display, XLoadQueryFont_ErrorHandler, NULL);
-	x_fs = XLoadQueryFont(gdi_display, lpstr);
-	if (X11DRV_check_error()) x_fs = 0;
-	wine_tsx11_unlock();
-	if (x_fs != 0)
+	if ((x_fs = safe_TSXLoadQueryFont(gdi_display, lpstr)) != 0)
 	{
 	    XFONT_SetFontMetric( fi, fr, x_fs );
 	    TSXFreeFont( gdi_display, x_fs );
@@ -2990,7 +3000,7 @@
   {
       XFontStruct*  x_fs;
       strcpy(buffer, "-*-*-*-*-normal-*-[12 0 0 12]-*-72-*-*-*-iso8859-1");
-      if( (x_fs = TSXLoadQueryFont(gdi_display, buffer)) )
+      if( (x_fs = safe_TSXLoadQueryFont(gdi_display, buffer)) )
       {
 	  text_caps |= TC_SF_X_YINDEP;
 	  TSXFreeFont(gdi_display, x_fs);
@@ -3132,7 +3142,7 @@
 	    do
 	    {
 		LFD_ComposeLFD( pfo, fm.height, lpLFD, uRelaxLevel++ );
-		if( (pfo->fs = TSXLoadQueryFont( gdi_display, lpLFD )) ) break;
+		if( (pfo->fs = safe_TSXLoadQueryFont( gdi_display, lpLFD )) ) break;
 	    } while( uRelaxLevel );
 
 


More information about the wine-patches mailing list