Patch 9.0.0550
Problem: Crash when closing a tabpage and buffer is NULL.
Solution: Adjust how autocommands are triggered when closing a window.
(closes #11198, closes #11197)
Files: src/ex_docmd.c, src/window.c, src/testdir/test_autocmd.vim
*** ../vim-9.0.0549/src/ex_docmd.c 2022-09-20 17:11:43.585765778 +0100
--- src/ex_docmd.c 2022-09-22 18:02:08.566725243 +0100
***************
*** 6304,6310 ****
{
int done = 0;
win_T *wp;
- int h = tabline_height();
// Limit to 1000 windows, autocommands may add a window while we close
// one. OK, so I'm paranoid...
--- 6304,6309 ----
***************
*** 6320,6329 ****
}
apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf);
-
- redraw_tabline = TRUE;
- if (h != tabline_height())
- shell_new_rows();
}
/*
--- 6319,6324 ----
*** ../vim-9.0.0549/src/window.c 2022-09-19 16:45:26.202239861 +0100
--- src/window.c 2022-09-22 18:07:46.803280727 +0100
***************
*** 2340,2346 ****
{
win_T *wp;
tabpage_T *tp, *nexttp;
- int h = tabline_height();
int count = tabpage_index(NULL);
++RedrawingDisabled;
--- 2340,2345 ----
***************
*** 2384,2393 ****
if (count != tabpage_index(NULL))
apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf);
-
- redraw_tabline = TRUE;
- if (h != tabline_height())
- shell_new_rows();
}
/*
--- 2383,2388 ----
***************
*** 2446,2463 ****
* that below.
*/
goto_tabpage_tp(alt_tabpage(), FALSE, TRUE);
- redraw_tabline = TRUE;
// Safety check: Autocommands may have closed the window when jumping
// to the other tab page.
if (valid_tabpage(prev_curtab) && prev_curtab->tp_firstwin == win)
- {
- int h = tabline_height();
-
win_close_othertab(win, free_buf, prev_curtab);
- if (h != tabline_height())
- shell_new_rows();
- }
#ifdef FEAT_JOB_CHANNEL
entering_window(curwin);
#endif
--- 2441,2451 ----
***************
*** 2656,2662 ****
--- 2644,2653 ----
&& win->w_buffer == NULL)
{
// Need to close the window anyway, since the buffer is NULL.
+ // Don't trigger autocmds with a NULL buffer.
+ block_autocmds();
win_close_othertab(win, FALSE, prev_curtab);
+ unblock_autocmds();
return FAIL;
}
***************
*** 2907,2912 ****
--- 2898,2905 ----
// When closing the last window in a tab page remove the tab page.
if (tp->tp_firstwin == tp->tp_lastwin)
{
+ int h = tabline_height();
+
if (tp == first_tabpage)
first_tabpage = tp->tp_next;
else
***************
*** 2922,2927 ****
--- 2915,2923 ----
ptp->tp_next = tp->tp_next;
}
free_tp = TRUE;
+ redraw_tabline = TRUE;
+ if (h != tabline_height())
+ shell_new_rows();
}
// Free the memory used for the window.
*** ../vim-9.0.0549/src/testdir/test_autocmd.vim 2022-09-09
17:09:32.204881239 +0100
--- src/testdir/test_autocmd.vim 2022-09-22 18:02:08.566725243 +0100
***************
*** 515,520 ****
--- 515,540 ----
augroup! test-WinClosed
endfunc
+ " This used to trigger WinClosed twice for the same window, and the window's
+ " buffer was NULL in the second autocommand.
+ func Test_WinClosed_switch_tab()
+ edit Xa
+ split Xb
+ split Xc
+ tab split
+ new
+ augroup test-WinClosed
+ autocmd WinClosed * tabprev | bwipe!
+ augroup END
+ close
+ " Check that the tabline has been fully removed
+ call assert_equal([1, 1], win_screenpos(0))
+
+ autocmd! test-WinClosed
+ augroup! test-WinClosed
+ %bwipe!
+ endfunc
+
func s:AddAnAutocmd()
augroup vimBarTest
au BufReadCmd * echo 'hello'
*** ../vim-9.0.0549/src/version.c 2022-09-22 17:33:58.158667760 +0100
--- src/version.c 2022-09-22 18:03:46.130917220 +0100
***************
*** 701,702 ****
--- 701,704 ----
{ /* Add new patch number below this line */
+ /**/
+ 550,
/**/
--
hundred-and-one symptoms of being an internet addict:
134. You consider bandwidth to be more important than carats.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220922171638.A61BF1C0796%40moolenaar.net.