changeset 83435:5efa63b61ac5

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
author Karoly Lorentey <lorentey@elte.hu>
date Fri, 30 Dec 2005 05:28:31 +0000
parents 944e6b68a0de
children f67e432d150c
files src/frame.c
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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.  */