# HG changeset patch # User Karoly Lorentey # Date 1135920511 0 # Node ID 5efa63b61ac5270ba818186c47f819d98679ccef # Parent 944e6b68a0deddd40bf92b43f068e3f551d048a5 Make sure `delete-frame-functions' can not prevent the frame from being deleted. * frame.c (delete_frame_handler): New function. (Fdelete_frame): Use it to invoke `delete-frame-functions' safely. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-475 diff -r 944e6b68a0de -r 5efa63b61ac5 src/frame.c --- a/src/frame.c Thu Dec 29 21:11:27 2005 +0000 +++ b/src/frame.c Fri Dec 30 05:28:31 2005 +0000 @@ -1324,6 +1324,14 @@ return 1; } +/* Error handler for `delete-frame-functions'. */ +static Lisp_Object +delete_frame_handler (Lisp_Object arg) +{ + add_to_log ("Error during `delete-frame': %s", arg, Qnil); + return Qnil; +} + DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "", doc: /* Delete FRAME, permanently eliminating it from use. If omitted, FRAME defaults to the selected frame. @@ -1398,10 +1406,18 @@ if (!NILP (Vrun_hooks) && NILP (Fframe_parameter (frame, intern ("tooltip")))) { + int count = SPECPDL_INDEX (); Lisp_Object args[2]; + struct gcpro gcpro1, gcpro2; + + /* Don't let a rogue function in `delete-frame-functions' + prevent the frame deletion. */ + GCPRO2 (args[0], args[1]); args[0] = intern ("delete-frame-functions"); args[1] = frame; - Frun_hook_with_args (2, args); + internal_condition_case_2 (Frun_hook_with_args, 2, args, + Qt, delete_frame_handler); + UNGCPRO; } /* The hook may sometimes (indirectly) cause the frame to be deleted. */