changeset 83108:c7a76f7d323c

Fix error on deleting an emacsclient terminal (Dan Nicolaescu). lisp/server.el (server-delete-client): Check that the buffer is live before switching to it. Also, check that the tty display still has live buffers before deleting it. (server-handle-delete-frame): Don't do anything if the frame was on a tty device (reported by Dan Nicolaescu). git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-148
author Karoly Lorentey <lorentey@elte.hu>
date Mon, 19 Apr 2004 14:16:10 +0000
parents 04f66a874a01
children 1707638677c9
files lisp/server.el
diffstat 1 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/server.el	Mon Apr 19 12:03:00 2004 +0000
+++ b/lisp/server.el	Mon Apr 19 14:16:10 2004 +0000
@@ -218,19 +218,21 @@
       (setq server-clients (delq client server-clients))
 
       (dolist (buf buffers)
-	(with-current-buffer buf
-	  ;; Remove PROC from the clients of each buffer.
-	  (setq server-buffer-clients (delq proc server-buffer-clients))
-	  ;; Kill the buffer if necessary.
-	  (when (and (null server-buffer-clients)
-		     (or (and server-kill-new-buffers
-			      (not server-existing-buffer))
-			 (server-temp-file-p)))
-	    (kill-buffer (current-buffer)))))
+	(when (buffer-live-p buf)
+	  (with-current-buffer buf
+	    ;; Remove PROC from the clients of each buffer.
+	    (setq server-buffer-clients (delq proc server-buffer-clients))
+	    ;; Kill the buffer if necessary.
+	    (when (and (null server-buffer-clients)
+		       (or (and server-kill-new-buffers
+				(not server-existing-buffer))
+			   (server-temp-file-p)))
+	      (kill-buffer (current-buffer))))))
 
       ;; Delete the client's tty.
       (let ((tty (server-client-get client 'tty)))
-	(when tty (delete-tty tty)))
+	(when (and tty (server-tty-live-p tty))
+	  (delete-tty tty)))
 
       ;; Delete the client's frames.
       (dolist (frame (frame-list))
@@ -279,7 +281,9 @@
 (defun server-handle-delete-frame (frame)
   "Delete the client connection when the emacsclient frame is deleted."
   (let ((proc (frame-parameter frame 'client)))
-    (when proc
+    (when (and proc (window-system frame))
+      ;; (Closing a terminal frame must not trigger a delete;
+      ;; we must wait for delete-tty-after-functions.)
       (server-log (format "server-handle-delete-frame, frame %s" frame) proc)
       (server-delete-client proc))))