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