changeset 756:00793f182d30

[xemacs-hg @ 2002-02-22 17:12:26 by michaels] 2002-02-11 Mike Sperber <mike@xemacs.org> * device-x.c: (x_IO_error_handler): (x_init_device): Temporarily keep device in static variable `device_being_initialized' so we can recover gracefully from internal XOpenDevice failure. (XOpenDevice is documented to return NULL on failure, but sometimes calls the IO error handler instead.)
author michaels
date Fri, 22 Feb 2002 17:12:27 +0000
parents da44ff90109f
children 516c347c4479
files src/ChangeLog src/device-x.c
diffstat 2 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sat Feb 16 07:25:39 2002 +0000
+++ b/src/ChangeLog	Fri Feb 22 17:12:27 2002 +0000
@@ -1,3 +1,13 @@
+2002-02-11  Mike Sperber  <mike@xemacs.org>
+
+	* device-x.c: 
+	(x_IO_error_handler):
+	(x_init_device): Temporarily keep device in static variable
+	`device_being_initialized' so we can recover gracefully from
+	internal XOpenDevice failure.  (XOpenDevice is documented to
+	return NULL on failure, but sometimes calls the IO error handler
+	instead.)
+
 2002-02-12  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* fileio.c (Ffind_file_name_handler): Improve docstring.
--- a/src/device-x.c	Sat Feb 16 07:25:39 2002 +0000
+++ b/src/device-x.c	Fri Feb 22 17:12:27 2002 +0000
@@ -168,6 +168,8 @@
 /*		      initializing an X connection			*/
 /************************************************************************/
 
+static struct device *device_being_initialized = NULL;
+
 static void
 allocate_x_device_struct (struct device *d)
 {
@@ -563,7 +565,9 @@
    */
   slow_down_interrupts ();
   /* May not be needed but XtOpenDisplay could not deal with signals here. */
+  device_being_initialized = d;
   dpy = DEVICE_X_DISPLAY (d) = XOpenDisplay (disp_name);
+  device_being_initialized = NULL;
   speed_up_interrupts ();
 
   if (dpy == 0)
@@ -1117,6 +1121,9 @@
   Lisp_Object dev;
   struct device *d = get_device_from_display_1 (disp);
 
+  if (!d)
+    d = device_being_initialized;
+
   assert (d != NULL);
   XSETDEVICE (dev, d);