Karsten Hopp b9b7f2
To: vim_dev@googlegroups.com
Karsten Hopp b9b7f2
Subject: Patch 7.3.557
Karsten Hopp b9b7f2
Fcc: outbox
Karsten Hopp b9b7f2
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp b9b7f2
Mime-Version: 1.0
Karsten Hopp b9b7f2
Content-Type: text/plain; charset=UTF-8
Karsten Hopp b9b7f2
Content-Transfer-Encoding: 8bit
Karsten Hopp b9b7f2
------------
Karsten Hopp b9b7f2
Karsten Hopp b9b7f2
Patch 7.3.557
Karsten Hopp b9b7f2
Problem:    Crash when an autocommand wipes out a buffer when it is hidden.
Karsten Hopp b9b7f2
Solution:   Restore the current window when needed. (Christian Brabandt)
Karsten Hopp b9b7f2
Files:	    src/buffer.c
Karsten Hopp b9b7f2
Karsten Hopp b9b7f2
Karsten Hopp b9b7f2
*** ../vim-7.3.556/src/buffer.c	2012-06-13 14:28:16.000000000 +0200
Karsten Hopp b9b7f2
--- src/buffer.c	2012-06-20 11:49:54.000000000 +0200
Karsten Hopp b9b7f2
***************
Karsten Hopp b9b7f2
*** 1363,1368 ****
Karsten Hopp b9b7f2
--- 1363,1369 ----
Karsten Hopp b9b7f2
      int		action;
Karsten Hopp b9b7f2
  {
Karsten Hopp b9b7f2
      buf_T	*prevbuf;
Karsten Hopp b9b7f2
+     win_T	*prevwin;
Karsten Hopp b9b7f2
      int		unload = (action == DOBUF_UNLOAD || action == DOBUF_DEL
Karsten Hopp b9b7f2
  						     || action == DOBUF_WIPE);
Karsten Hopp b9b7f2
  
Karsten Hopp b9b7f2
***************
Karsten Hopp b9b7f2
*** 1402,1423 ****
Karsten Hopp b9b7f2
  	if (buf_valid(prevbuf))
Karsten Hopp b9b7f2
  #endif
Karsten Hopp b9b7f2
  	{
Karsten Hopp b9b7f2
  	    if (prevbuf == curbuf)
Karsten Hopp b9b7f2
  		u_sync(FALSE);
Karsten Hopp b9b7f2
  	    close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf,
Karsten Hopp b9b7f2
  		    unload ? action : (action == DOBUF_GOTO
Karsten Hopp b9b7f2
  			&& !P_HID(prevbuf)
Karsten Hopp b9b7f2
  			&& !bufIsChanged(prevbuf)) ? DOBUF_UNLOAD : 0, FALSE);
Karsten Hopp b9b7f2
  	}
Karsten Hopp b9b7f2
      }
Karsten Hopp b9b7f2
  #ifdef FEAT_AUTOCMD
Karsten Hopp b9b7f2
      /* An autocommand may have deleted "buf", already entered it (e.g., when
Karsten Hopp b9b7f2
!      * it did ":bunload") or aborted the script processing! */
Karsten Hopp b9b7f2
! # ifdef FEAT_EVAL
Karsten Hopp b9b7f2
!     if (buf_valid(buf) && buf != curbuf && !aborting())
Karsten Hopp b9b7f2
! # else
Karsten Hopp b9b7f2
!     if (buf_valid(buf) && buf != curbuf)
Karsten Hopp b9b7f2
! # endif
Karsten Hopp b9b7f2
  #endif
Karsten Hopp b9b7f2
  	enter_buffer(buf);
Karsten Hopp b9b7f2
  }
Karsten Hopp b9b7f2
--- 1403,1432 ----
Karsten Hopp b9b7f2
  	if (buf_valid(prevbuf))
Karsten Hopp b9b7f2
  #endif
Karsten Hopp b9b7f2
  	{
Karsten Hopp b9b7f2
+ 	    prevwin = curwin;
Karsten Hopp b9b7f2
  	    if (prevbuf == curbuf)
Karsten Hopp b9b7f2
  		u_sync(FALSE);
Karsten Hopp b9b7f2
  	    close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf,
Karsten Hopp b9b7f2
  		    unload ? action : (action == DOBUF_GOTO
Karsten Hopp b9b7f2
  			&& !P_HID(prevbuf)
Karsten Hopp b9b7f2
  			&& !bufIsChanged(prevbuf)) ? DOBUF_UNLOAD : 0, FALSE);
Karsten Hopp b9b7f2
+ 	    if (curwin != prevwin && win_valid(prevwin))
Karsten Hopp b9b7f2
+ 	      /* autocommands changed curwin, Grr! */
Karsten Hopp b9b7f2
+ 	      curwin = prevwin;
Karsten Hopp b9b7f2
  	}
Karsten Hopp b9b7f2
      }
Karsten Hopp b9b7f2
  #ifdef FEAT_AUTOCMD
Karsten Hopp b9b7f2
      /* An autocommand may have deleted "buf", already entered it (e.g., when
Karsten Hopp b9b7f2
!      * it did ":bunload") or aborted the script processing!
Karsten Hopp b9b7f2
!      * If curwin->w_buffer is null, enter_buffer() will make it valid again */
Karsten Hopp b9b7f2
!     if ((buf_valid(buf) && buf != curbuf
Karsten Hopp b9b7f2
! #ifdef FEAT_EVAL
Karsten Hopp b9b7f2
! 	    && !aborting()
Karsten Hopp b9b7f2
! #endif
Karsten Hopp b9b7f2
! #ifdef FEAT_WINDOWS
Karsten Hopp b9b7f2
! 	 ) || curwin->w_buffer == NULL
Karsten Hopp b9b7f2
! #endif
Karsten Hopp b9b7f2
!        )
Karsten Hopp b9b7f2
  #endif
Karsten Hopp b9b7f2
  	enter_buffer(buf);
Karsten Hopp b9b7f2
  }
Karsten Hopp b9b7f2
*** ../vim-7.3.556/src/version.c	2012-06-14 20:59:20.000000000 +0200
Karsten Hopp b9b7f2
--- src/version.c	2012-06-20 11:53:56.000000000 +0200
Karsten Hopp b9b7f2
***************
Karsten Hopp b9b7f2
*** 716,717 ****
Karsten Hopp b9b7f2
--- 716,719 ----
Karsten Hopp b9b7f2
  {   /* Add new patch number below this line */
Karsten Hopp b9b7f2
+ /**/
Karsten Hopp b9b7f2
+     557,
Karsten Hopp b9b7f2
  /**/
Karsten Hopp b9b7f2
Karsten Hopp b9b7f2
-- 
Karsten Hopp b9b7f2
Don't read everything you believe.
Karsten Hopp b9b7f2
Karsten Hopp b9b7f2
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp b9b7f2
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp b9b7f2
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp b9b7f2
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///