diff src/device.c @ 155:43dd3413c7c7 r20-3b4

Import from CVS: tag r20-3b4
author cvs
date Mon, 13 Aug 2007 09:39:39 +0200
parents cca96a509cfe
children 3d6bfa290dbd
line wrap: on
line diff
--- a/src/device.c	Mon Aug 13 09:38:27 2007 +0200
+++ b/src/device.c	Mon Aug 13 09:39:39 2007 +0200
@@ -495,6 +495,14 @@
   return device;
 }
 
+static Lisp_Object
+delete_deviceless_console(Lisp_Object console)
+{
+  if (NILP (XCONSOLE (console)->device_list))
+    Fdelete_console(console, Qnil);
+  return Qnil;
+}
+
 DEFUN ("make-device", Fmake_device, 2, 3, 0, /*
 Create a new device of type TYPE, attached to connection CONNECTION.
 
@@ -521,6 +529,7 @@
   Lisp_Object console = Qnil;
   Lisp_Object name = Qnil;
   struct console_methods *conmeths;
+  int speccount = specpdl_depth();
 
   struct gcpro gcpro1, gcpro2, gcpro3;
 #ifdef HAVE_X_WINDOWS
@@ -563,6 +572,8 @@
     console = create_console (name, type, conconnect, props);
   }
 
+  record_unwind_protect(delete_deviceless_console, console);
+
   con = XCONSOLE (console);
   d = allocate_device (console);
   XSETDEVICE (device, d);
@@ -602,6 +613,7 @@
   setup_device_initial_specifier_tags (d);
 
   UNGCPRO;
+  unbind_to(speccount, Qnil);
   return device;
 }