To:
[email protected]
Subject: Patch 7.4a.042
Fcc: outbox
From: Bram Moolenaar <
[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 7.4a.042
Problem: Crash when BufUnload autocommands close all buffers. (Andrew
Pimlott)
Solution: Set curwin->w_buffer to curbuf to avoid NULL.
Files: src/window.c, src/testdir/test8.in, src/testdir/test8.ok
*** ../vim-7.4a.041/src/window.c 2013-07-17 17:15:21.000000000 +0200
--- src/window.c 2013-07-24 15:55:34.000000000 +0200
***************
*** 2291,2298 ****
if (only_one_window() && win_valid(win) && win->w_buffer == NULL
&& (last_window() || curtab != prev_curtab
|| close_last_window_tabpage(win, free_buf, prev_curtab)))
! /* Autocommands have close all windows, quit now. */
getout(0);
/* Autocommands may have closed the window already, or closed the only
* other window or moved to another tab page. */
--- 2291,2303 ----
if (only_one_window() && win_valid(win) && win->w_buffer == NULL
&& (last_window() || curtab != prev_curtab
|| close_last_window_tabpage(win, free_buf, prev_curtab)))
! {
! /* Autocommands have close all windows, quit now. Restore
! * curwin->w_buffer, otherwise writing viminfo may fail. */
! if (curwin->w_buffer == NULL)
! curwin->w_buffer = curbuf;
getout(0);
+ }
/* Autocommands may have closed the window already, or closed the only
* other window or moved to another tab page. */
*** ../vim-7.4a.041/src/testdir/test8.in 2010-05-15 13:04:10.000000000 +0200
--- src/testdir/test8.in 2013-07-24 15:55:09.000000000 +0200
***************
*** 1,4 ****
--- 1,5 ----
Test for BufWritePre autocommand that deletes or unloads the buffer.
+ Test for BufUnload autocommand that unloads all other buffers.
STARTTEST
:so small.vim
***************
*** 16,21 ****
--- 17,43 ----
:bwipe test.out " remove test.out from the buffer list
:w " write it, will delete the buffer and give an error msg
:w >>test.out " Append contents of this file
+ :au! BufWritePre
+ :func CloseAll()
+ let i = 0
+ while i <= bufnr('$')
+ if i != bufnr('%') && bufloaded(i)
+ exe i . "bunload"
+ endif
+ let i += 1
+ endwhile
+ endfunc
+ :func WriteToOut()
+ edit! test.out
+ $put ='VimLeave done'
+ write
+ endfunc
+ :set viminfo='100,nviminfo
+ :au BufUnload * call CloseAll()
+ :au VimLeave * call WriteToOut()
+ :e small.vim
+ :sp mbyte.vim
+ :q
:qa!
ENDTEST
*** ../vim-7.4a.041/src/testdir/test8.ok 2010-05-15 13:04:10.000000000 +0200
--- src/testdir/test8.ok 2013-07-24 15:40:16.000000000 +0200
***************
*** 4,6 ****
--- 4,7 ----
start of Xxx1
test
end of Xxx
+ VimLeave done
*** ../vim-7.4a.041/src/version.c 2013-07-24 15:02:00.000000000 +0200
--- src/version.c 2013-07-24 15:55:54.000000000 +0200
***************
*** 729,730 ****
--- 729,732 ----
{ /* Add new patch number below this line */
+ /**/
+ 42,
/**/
--
hundred-and-one symptoms of being an internet addict:
23. You can't call your mother...she doesn't have a modem.
/// Bram Moolenaar --
[email protected] --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///