diff options
| author | Po Lu | 2022-10-26 21:46:41 +0800 |
|---|---|---|
| committer | Po Lu | 2022-10-26 21:46:58 +0800 |
| commit | 4a1e77ced6b3d00e9ffde5855dbc3df8f9ecd619 (patch) | |
| tree | 6c22a37a232e193a3527e7941f13ff327aef3637 /src | |
| parent | 38bcad545125a2cda218835b0210f24ab8db1e9e (diff) | |
| download | emacs-4a1e77ced6b3d00e9ffde5855dbc3df8f9ecd619.tar.gz emacs-4a1e77ced6b3d00e9ffde5855dbc3df8f9ecd619.zip | |
Prevent gui_consider_frame_title from restoring dead top frames
* src/xdisp.c (unwind_format_mode_line): Check that
old_top_frame is live before selecting it. It could have been
deleted, which leads to signals when the post-command-hook
installed by xterm-set-window-title runs upon the last frame of
a terminal being deleted.
(gui_consider_frame_title): Rearrange code to be more
understandable.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 1f7ac269e4e..557cb606317 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -13334,7 +13334,10 @@ unwind_format_mode_line (Lisp_Object vector) | |||
| 13334 | if (!EQ (frame, WINDOW_FRAME (XWINDOW (old_window)))) | 13334 | if (!EQ (frame, WINDOW_FRAME (XWINDOW (old_window)))) |
| 13335 | Fselect_window (target_frame_window, Qt); | 13335 | Fselect_window (target_frame_window, Qt); |
| 13336 | 13336 | ||
| 13337 | if (!NILP (old_top_frame) && !EQ (old_top_frame, frame)) | 13337 | if (!NILP (old_top_frame) && !EQ (old_top_frame, frame) |
| 13338 | /* This could've been destroyed during the formatting, | ||
| 13339 | possibly because the terminal was deleted. */ | ||
| 13340 | && FRAME_LIVE_P (XFRAME (old_top_frame))) | ||
| 13338 | Fselect_frame (old_top_frame, Qt); | 13341 | Fselect_frame (old_top_frame, Qt); |
| 13339 | } | 13342 | } |
| 13340 | 13343 | ||
| @@ -13437,6 +13440,7 @@ void | |||
| 13437 | gui_consider_frame_title (Lisp_Object frame) | 13440 | gui_consider_frame_title (Lisp_Object frame) |
| 13438 | { | 13441 | { |
| 13439 | struct frame *f = XFRAME (frame); | 13442 | struct frame *f = XFRAME (frame); |
| 13443 | Lisp_Object format_data; | ||
| 13440 | 13444 | ||
| 13441 | if ((FRAME_WINDOW_P (f) | 13445 | if ((FRAME_WINDOW_P (f) |
| 13442 | || FRAME_MINIBUF_ONLY_P (f) | 13446 | || FRAME_MINIBUF_ONLY_P (f) |
| @@ -13481,15 +13485,19 @@ gui_consider_frame_title (Lisp_Object frame) | |||
| 13481 | specbind (Qinhibit_redisplay, Qt); | 13485 | specbind (Qinhibit_redisplay, Qt); |
| 13482 | 13486 | ||
| 13483 | /* Switch to the buffer of selected window of the frame. Set up | 13487 | /* Switch to the buffer of selected window of the frame. Set up |
| 13484 | mode_line_target so that display_mode_element will output into | 13488 | mode_line_target so that display_mode_element will output |
| 13485 | mode_line_noprop_buf; then display the title. */ | 13489 | into mode_line_noprop_buf; then display the title. Save the |
| 13486 | record_unwind_protect (unwind_format_mode_line, | 13490 | original frame and selected window, and possibly the topmost |
| 13487 | format_mode_line_unwind_data | 13491 | frame of the tty (for tty frames) into a vector; it will be |
| 13488 | (f, current_buffer, selected_window, false)); | 13492 | restored later. */ |
| 13493 | |||
| 13494 | format_data = format_mode_line_unwind_data (f, current_buffer, | ||
| 13495 | selected_window, | ||
| 13496 | false); | ||
| 13497 | record_unwind_protect (unwind_format_mode_line, format_data); | ||
| 13489 | 13498 | ||
| 13490 | Fselect_window (f->selected_window, Qt); | 13499 | Fselect_window (f->selected_window, Qt); |
| 13491 | set_buffer_internal_1 | 13500 | set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->contents)); |
| 13492 | (XBUFFER (XWINDOW (f->selected_window)->contents)); | ||
| 13493 | fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; | 13501 | fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; |
| 13494 | 13502 | ||
| 13495 | mode_line_target = MODE_LINE_TITLE; | 13503 | mode_line_target = MODE_LINE_TITLE; |
| @@ -13502,8 +13510,9 @@ gui_consider_frame_title (Lisp_Object frame) | |||
| 13502 | /* Make sure that any raw bytes in the title are properly | 13510 | /* Make sure that any raw bytes in the title are properly |
| 13503 | represented by their multibyte sequences. */ | 13511 | represented by their multibyte sequences. */ |
| 13504 | ptrdiff_t nchars = 0; | 13512 | ptrdiff_t nchars = 0; |
| 13505 | len = str_as_multibyte ((unsigned char *)title, | 13513 | len = str_as_multibyte ((unsigned char *) title, |
| 13506 | mode_line_noprop_buf_end - title, len, &nchars); | 13514 | mode_line_noprop_buf_end - title, |
| 13515 | len, &nchars); | ||
| 13507 | unbind_to (count, Qnil); | 13516 | unbind_to (count, Qnil); |
| 13508 | 13517 | ||
| 13509 | /* Set the title only if it's changed. This avoids consing in | 13518 | /* Set the title only if it's changed. This avoids consing in |