Commit e519a50b authored by Karoly Lorentey's avatar Karoly Lorentey

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
parent 626ea340
......@@ -1484,7 +1484,8 @@ selected frame's terminal)."
;; 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))))
......
......@@ -314,7 +314,8 @@ message."
(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 @@ message."
(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)
......
......@@ -4326,7 +4326,14 @@ when the mouse is over clickable text. */);
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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment