From 17d85edc868b1cf780fac7cc299bf1098b977190 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Tue, 13 Apr 1999 00:51:52 +0000 Subject: [PATCH] Trap X errors so that Emacs doesn't die by them. --- src/xterm.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index 86fd43ac162..629e2946d95 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -6505,12 +6505,22 @@ x_list_fonts (f, pattern, size, maxnames) /* 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 @@ x_list_fonts (f, pattern, size, maxnames) } 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 @@ x_list_fonts (f, pattern, size, maxnames) 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) -- 2.39.5