changeset 34956:c26b7651dd9f

(x_connection_closed): Catch X errors around all statements that call X. Save away the error message in a local copy.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 02 Jan 2001 13:57:17 +0000
parents efabd2ba9997
children 30e820420803
files src/xterm.c
diffstat 1 files changed, 26 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/xterm.c	Tue Jan 02 13:57:02 2001 +0000
+++ b/src/xterm.c	Tue Jan 02 13:57:17 2001 +0000
@@ -11250,10 +11250,14 @@
   signal (signalnum, x_connection_signal);
 #endif /* USG */
 }
+
 
-/* Handling X errors.  */
-
-/* Handle the loss of connection to display DISPLAY.  */
+/************************************************************************
+			  Handling X errors
+ ************************************************************************/
+
+/* Handle the loss of connection to display DPY.  ERROR_MESSAGE is
+   the text of an error message that lead to the connection loss.  */
 
 static SIGTYPE
 x_connection_closed (dpy, error_message)
@@ -11262,9 +11266,19 @@
 {
   struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
   Lisp_Object frame, tail;
-
+  int count;
+  char *msg;
+  
+  msg = (char *) alloca (strlen (error_message) + 1);
+  strcpy (msg, error_message);
   handling_signal = 0;
   
+  /* Prevent being called recursively because of an error condition
+     below.  Otherwise, we might end up with printing ``can't find per
+     display information'' in the recursive call instead of printing
+     the original message here.  */
+  count = x_catch_errors (dpy);
+  
   /* We have to close the display to inform Xt that it doesn't
      exist anymore.  If we don't, Xt will continue to wait for
      events from the display.  As a consequence, a sequence of
@@ -11281,15 +11295,7 @@
      in OpenWindows.  I don't know how to cicumvent it here.  */
   
 #ifdef USE_X_TOOLKIT
-  {
-    /* Prevent being called recursively because of an error condition
-       in XtCloseDisplay.  Otherwise, we might end up with printing
-       ``can't find per display information'' in the recursive call
-       instead of printing the original message here.  */
-    int count = x_catch_errors (dpy);
-    XtCloseDisplay (dpy);
-    x_uncatch_errors (dpy, count);
-  }
+  XtCloseDisplay (dpy);
 #endif
 
   /* Indicate that this display is dead.  */
@@ -11326,9 +11332,11 @@
   if (dpyinfo)
     x_delete_display (dpyinfo);
 
+  x_uncatch_errors (dpy, count);
+  
   if (x_display_list == 0)
     {
-      fprintf (stderr, "%s\n", error_message);
+      fprintf (stderr, "%s\n", msg);
       shut_down_emacs (0, 0, Qnil);
       exit (70);
     }
@@ -11341,8 +11349,9 @@
   TOTALLY_UNBLOCK_INPUT;
 
   clear_waiting_for_input ();
-  error ("%s", error_message);
-}
+  error ("%s", msg);
+}
+
 
 /* This is the usual handler for X protocol errors.
    It kills all frames on the display that we got the error for.
@@ -11364,6 +11373,7 @@
   x_connection_closed (display, buf1);
 }
 
+
 /* This is the first-level handler for X protocol errors.
    It calls x_error_quitter or x_error_catcher.  */