summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/term.c12
-rw-r--r--src/termhooks.h6
-rw-r--r--src/terminal.c8
-rw-r--r--src/xterm.c18
4 files changed, 35 insertions, 9 deletions
diff --git a/src/term.c b/src/term.c
index 00900ae96f4..3076e8939f1 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2970,9 +2970,6 @@ fatal (str, arg1, arg2)
-static int deleting_tty = 0;
-
-
/* Delete the given tty terminal, closing all frames on it. */
static void
@@ -2983,9 +2980,9 @@ delete_tty (struct terminal *terminal)
char *tty_name;
int last_terminal;
- if (deleting_tty)
- /* We get a recursive call when we delete the last frame on this
- terminal. */
+ /* Protect against recursive calls. Fdelete_frame calls us back
+ when we delete our last frame. */
+ if (terminal->deleted)
return;
if (terminal->type != output_termcap)
@@ -3022,7 +3019,8 @@ delete_tty (struct terminal *terminal)
tty->next = 0;
}
- deleting_tty = 1;
+ /* We must not throw any errors below this line. */
+ terminal->deleted = 1;
FOR_EACH_FRAME (tail, frame)
{
diff --git a/src/termhooks.h b/src/termhooks.h
index 8937a709f85..46fb0c453f5 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -299,7 +299,11 @@ struct terminal
/* The number of frames that are on this terminal. */
int reference_count;
-
+
+ /* Nonzero while deleting this terminal. Used to protect against
+ recursive calls to delete_terminal_hook. */
+ int deleted;
+
/* The type of the terminal device. */
enum output_method type;
diff --git a/src/terminal.c b/src/terminal.c
index fa6a0a4f51e..db75e16b6cf 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -277,7 +277,13 @@ delete_terminal (struct terminal *terminal)
{
struct terminal **tp;
Lisp_Object tail, frame;
-
+
+ /* Protect against recursive calls. Fdelete_frame calls us back
+ when we delete our last frame. */
+ if (terminal->deleted)
+ return;
+ terminal->deleted = 1;
+
/* Check for and close live frames that are still on this
terminal. */
FOR_EACH_FRAME (tail, frame)
diff --git a/src/xterm.c b/src/xterm.c
index 2070c65d76a..04242f2af3b 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10837,6 +10837,24 @@ x_delete_terminal (struct terminal *terminal)
{
struct x_display_info *dpyinfo = terminal->display_info.x;
int i;
+ Lisp_Object tail, frame;
+
+ /* Protect against recursive calls. Fdelete_frame calls us back
+ when we delete our last frame. */
+ if (terminal->deleted)
+ return;
+ terminal->deleted = 1;
+
+ /* Check for and close live frames that are still on this
+ terminal. */
+ FOR_EACH_FRAME (tail, frame)
+ {
+ struct frame *f = XFRAME (frame);
+ if (FRAME_LIVE_P (f) && f->terminal == terminal)
+ {
+ Fdelete_frame (frame, Qt);
+ }
+ }
BLOCK_INPUT;
/* Free the fonts in the font table. */