From 28d4952d423a088a53a82c8e02f283fa98b7e20d Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 29 May 2022 08:51:17 +0800 Subject: [PATCH] Improve error trapping on X * xterm.c (x_uncatch_errors, x_had_errors_p): Don't sync if no request was made since the error trap was installed. --- src/xterm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index 5c591134692..3e5aaf5d4a4 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -21265,7 +21265,11 @@ x_uncatch_errors (void) /* There is no point in making this extra sync if all requests are known to have been fully processed. */ && (LastKnownRequestProcessed (x_error_message->dpy) - != NextRequest (x_error_message->dpy) - 1)) + != NextRequest (x_error_message->dpy) - 1) + /* Likewise if no request was made since the trap was + installed. */ + && (NextRequest (x_error_message->dpy) + > x_error_message->first_request)) XSync (x_error_message->dpy, False); tmp = x_error_message; @@ -21315,8 +21319,10 @@ x_had_errors_p (Display *dpy) emacs_abort (); /* Make sure to catch any errors incurred so far. */ - if (LastKnownRequestProcessed (dpy) - != NextRequest (dpy) - 1) + if ((LastKnownRequestProcessed (dpy) + != NextRequest (dpy) - 1) + && (NextRequest (dpy) + > x_error_message->first_request)) XSync (dpy, False); return x_error_message->string[0] != 0; -- 2.39.2