diff src/xterm.c @ 24618:b18f51ec1b6c

Trap X errors so that Emacs doesn't die by them.
author Kenichi Handa <handa@m17n.org>
date Tue, 13 Apr 1999 00:51:52 +0000
parents 6f4ae209bbac
children c7d905dca6ba
line wrap: on
line diff
--- a/src/xterm.c	Mon Apr 12 18:25:26 1999 +0000
+++ b/src/xterm.c	Tue Apr 13 00:51:52 1999 +0000
@@ -6505,12 +6505,22 @@
       /* At first, put PATTERN in the cache.  */
 
       BLOCK_INPUT;
+      count = x_catch_errors (dpy);
+
       if (try_XLoadQueryFont)
 	{
 	  XFontStruct *font;
 	  unsigned long value;
 
 	  font = XLoadQueryFont (dpy, XSTRING (pattern)->data);
+	  if (x_had_errors_p (dpy))
+	    {
+	      /* This error is perhaps due to insufficient memory on X
+                 server.  Let's just ignore it.  */
+	      font = NULL;
+	      x_clear_errors (dpy);
+	    }
+
 	  if (font
 	      && XGetFontProperty (font, XA_FONT, &value))
 	    {
@@ -6542,10 +6552,21 @@
 	}
 
       if (!try_XLoadQueryFont)
-	/* We try at least 10 fonts because XListFonts will return
-	   auto-scaled fonts at the head.  */
-	names = XListFonts (dpy, XSTRING (pattern)->data, max (maxnames, 10),
-			    &num_fonts);
+	{
+	  /* We try at least 10 fonts because XListFonts will return
+	     auto-scaled fonts at the head.  */
+	  names = XListFonts (dpy, XSTRING (pattern)->data, max (maxnames, 10),
+			      &num_fonts);
+	  if (x_had_errors_p (dpy))
+	    {
+	      /* This error is perhaps due to insufficient memory on X
+                 server.  Let's just ignore it.  */
+	      names = NULL;
+	      x_clear_errors (dpy);
+	    }
+	}
+
+      x_uncatch_errors (dpy, count);
       UNBLOCK_INPUT;
 
       if (names)
@@ -6627,8 +6648,17 @@
 	      XFontStruct *thisinfo;
 
 	      BLOCK_INPUT;
+	      count = x_catch_errors (dpy);
 	      thisinfo = XLoadQueryFont (dpy,
 					 XSTRING (XCONS (tem)->car)->data);
+	      if (x_had_errors_p (dpy))
+		{
+		  /* This error is perhaps due to insufficient memory on X
+		     server.  Let's just ignore it.  */
+		  thisinfo = NULL;
+		  x_clear_errors (dpy);
+		}
+	      x_uncatch_errors (dpy, count);
 	      UNBLOCK_INPUT;
 
 	      if (thisinfo)