changeset 83335:60208d3a0bb1

Handle and document that `delete-frame' may call functions in `delete-frame-functions' twice. * src/frame.c (syms_of_frame): Add warning to `delete-frame-functions' description. * lisp/frame.el (terminal-handle-delete-frame): Check that the frame is alive. * lisp/server.el (server-handle-delete-frame): Ditto. Remove bogus comment. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-375
author Karoly Lorentey <lorentey@elte.hu>
date Wed, 06 Jul 2005 01:41:56 +0000
parents 6afa124501e6
children 24c69010999c
files lisp/frame.el lisp/server.el src/frame.c
diffstat 3 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/frame.el	Wed Jul 06 00:42:58 2005 +0000
+++ b/lisp/frame.el	Wed Jul 06 01:41:56 2005 +0000
@@ -1484,7 +1484,8 @@
   ;; XXX We assume that the display is closed immediately after the
   ;; last frame is deleted on it.  It would be better to create a hook
   ;; called `delete-display-functions', and use it instead.
-  (when (= 1 (length (frames-on-display-list (frame-display frame))))
+  (when (and (frame-live-p frame)
+	     (= 1 (length (frames-on-display-list (frame-display frame)))))
     (setq terminal-parameter-alist
 	  (assq-delete-all (frame-display frame) terminal-parameter-alist))))
 
--- a/lisp/server.el	Wed Jul 06 00:42:58 2005 +0000
+++ b/lisp/server.el	Wed Jul 06 01:41:56 2005 +0000
@@ -314,7 +314,8 @@
 (defun server-handle-delete-frame (frame)
   "Delete the client connection when the emacsclient frame is deleted."
   (let ((proc (frame-parameter frame 'client)))
-    (when (and proc
+    (when (and (frame-live-p frame)
+	       proc
 	       (or (window-system frame)
 		   ;; A terminal display must not yet be deleted if
 		   ;; there are other frames on it.
@@ -326,10 +327,6 @@
 				(frame-list))
 			  frame-num))))
       (server-log (format "server-handle-delete-frame, frame %s" frame) proc)
-      ;; XXX Deleting the process causes emacsclient to exit
-      ;; immediately, which might happen before Emacs closes the
-      ;; display.  I think we need a `delete-frame-after-functions'
-      ;; hook here.
       (server-delete-client proc 'noframe)))) ; Let delete-frame delete the frame later.
 
 (defun server-handle-suspend-tty (display)
--- a/src/frame.c	Wed Jul 06 00:42:58 2005 +0000
+++ b/src/frame.c	Wed Jul 06 01:41:56 2005 +0000
@@ -4326,7 +4326,14 @@
   DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions,
 	       doc: /* Functions to be run before deleting a frame.
 The functions are run with one arg, the frame to be deleted.
-See `delete-frame'.  */);
+See `delete-frame'.
+
+Note that functions in this list may be called twice on the same
+frame.  In the second invocation, the frame is already deleted, and
+the function should do nothing.  (You can use `frame-live-p' to check
+for this.)  This wrinkle happens when an earlier function in
+`delete-frame-functions' (indirectly) calls delete-frame
+recursively.  */);
   Vdelete_frame_functions = Qnil;
 
   DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame,