summaryrefslogtreecommitdiff
path: root/src/terminal.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-08-13 14:13:19 +0200
committerBram Moolenaar <Bram@vim.org>2017-08-13 14:13:19 +0200
commit679653e59c6da7f6abc29470ef9d404582bacbb9 (patch)
tree8a4dc65c4d861d43dc376c4f844755545ee1d8f3 /src/terminal.c
parent55b6926450d75788dada3ff44a35e328224df758 (diff)
downloadvim-git-679653e59c6da7f6abc29470ef9d404582bacbb9.tar.gz
patch 8.0.0923: crash in GUI when terminal job exitsv8.0.0923
Problem: Crash in GUI when terminal job exits. (Kazunobu Kuriyama) Solution: reset in_terminal_loop when a terminal is freed.
Diffstat (limited to 'src/terminal.c')
-rw-r--r--src/terminal.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/terminal.c b/src/terminal.c
index 6d01a299c..317615cfd 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -34,9 +34,10 @@
*
* When the job ends the text is put in a buffer. Redrawing then happens from
* that buffer, attributes come from the scrollback buffer tl_scrollback.
+ * When the buffer is changed it is turned into a normal buffer, the attributes
+ * in tl_scrollback are no longer used.
*
* TODO:
- * - cursor shape/color/blink in the GUI
* - Make argument list work on MS-Windows. #1954
* - MS-Windows: no redraw for 'updatetime' #1915
* - To set BS correctly, check get_stty(); Pass the fd of the pty.
@@ -524,6 +525,8 @@ free_terminal(buf_T *buf)
vim_free(term->tl_cursor_color);
vim_free(term);
buf->b_term = NULL;
+ if (in_terminal_loop == term)
+ in_terminal_loop = NULL;
}
/*
@@ -1014,6 +1017,8 @@ term_enter_job_mode()
/*
* Get a key from the user without mapping.
+ * Note: while waiting a terminal may be closed and freed if the channel is
+ * closed and ++close was used.
* TODO: use terminal mode mappings.
*/
static int
@@ -1140,10 +1145,16 @@ term_paste_register(int prev_c UNUSED)
#ifdef FEAT_CMDL_INFO
clear_showcmd();
#endif
+ if (!term_use_loop())
+ /* job finished while waiting for a character */
+ return;
/* CTRL-W "= prompt for expression to evaluate. */
if (c == '=' && get_expr_register() != '=')
return;
+ if (!term_use_loop())
+ /* job finished while waiting for a character */
+ return;
l = (list_T *)get_reg_contents(c, GREG_LIST);
if (l != NULL)
@@ -1272,6 +1283,10 @@ terminal_loop(void)
int termkey = 0;
int ret;
+ /* Remember the terminal we are sending keys to. However, the terminal
+ * might be closed while waiting for a character, e.g. typing "exit" in a
+ * shell and ++close was used. Therefore use curbuf->b_term instead of a
+ * stored reference. */
in_terminal_loop = curbuf->b_term;
if (*curwin->w_p_tk != NUL)