forked from aniani/vim
patch 7.4.2309
Problem: Crash when doing tabnext in a BufUnload autocmd. (Dominique Pelle) Solution: When detecting that the tab page changed, don't just abort but delete the window where w_buffer is NULL.
This commit is contained in:
@@ -218,4 +218,18 @@ function Test_tabpage_with_tab_modifier()
|
|||||||
bw!
|
bw!
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
func Test_tabnext_on_buf_unload()
|
||||||
|
" This once caused a crash
|
||||||
|
new
|
||||||
|
tabedit
|
||||||
|
tabfirst
|
||||||
|
au BufUnload <buffer> tabnext
|
||||||
|
q
|
||||||
|
|
||||||
|
while tabpagenr('$') > 1
|
||||||
|
quit
|
||||||
|
endwhile
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -763,6 +763,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2309,
|
||||||
/**/
|
/**/
|
||||||
2308,
|
2308,
|
||||||
/**/
|
/**/
|
||||||
|
22
src/window.c
22
src/window.c
@@ -2379,7 +2379,7 @@ win_close(win_T *win, int free_buf)
|
|||||||
#endif
|
#endif
|
||||||
close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, TRUE);
|
close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, TRUE);
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
if (win_valid(win))
|
if (win_valid_any_tab(win))
|
||||||
win->w_closing = FALSE;
|
win->w_closing = FALSE;
|
||||||
#endif
|
#endif
|
||||||
/* Make sure curbuf is valid. It can become invalid if 'bufhidden' is
|
/* Make sure curbuf is valid. It can become invalid if 'bufhidden' is
|
||||||
@@ -2399,9 +2399,18 @@ win_close(win_T *win, int free_buf)
|
|||||||
getout(0);
|
getout(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Autocommands may have closed the window already, or closed the only
|
/* Autocommands may have moved to another tab page. */
|
||||||
* other window or moved to another tab page. */
|
if (curtab != prev_curtab && win_valid_any_tab(win)
|
||||||
else if (!win_valid(win) || last_window() || curtab != prev_curtab
|
&& win->w_buffer == NULL)
|
||||||
|
{
|
||||||
|
/* Need to close the window anyway, since the buffer is NULL. */
|
||||||
|
win_close_othertab(win, FALSE, prev_curtab);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Autocommands may have closed the window already or closed the only
|
||||||
|
* other window. */
|
||||||
|
if (!win_valid(win) || last_window()
|
||||||
|| close_last_window_tabpage(win, free_buf, prev_curtab))
|
|| close_last_window_tabpage(win, free_buf, prev_curtab))
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
@@ -2492,10 +2501,13 @@ win_close_othertab(win_T *win, int free_buf, tabpage_T *tp)
|
|||||||
int free_tp = FALSE;
|
int free_tp = FALSE;
|
||||||
|
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
if (win->w_closing || win->w_buffer->b_closing)
|
/* Get here with win->w_buffer == NULL when win_close() detects the tab
|
||||||
|
* page changed. */
|
||||||
|
if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_closing))
|
||||||
return; /* window is already being closed */
|
return; /* window is already being closed */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (win->w_buffer != NULL)
|
||||||
/* Close the link to the buffer. */
|
/* Close the link to the buffer. */
|
||||||
close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, FALSE);
|
close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, FALSE);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user