Blame SOURCES/7.4.004

d6ba96
To: vim_dev@googlegroups.com
d6ba96
Subject: Patch 7.4.004
d6ba96
Fcc: outbox
d6ba96
From: Bram Moolenaar <Bram@moolenaar.net>
d6ba96
Mime-Version: 1.0
d6ba96
Content-Type: text/plain; charset=UTF-8
d6ba96
Content-Transfer-Encoding: 8bit
d6ba96
------------
d6ba96
d6ba96
Patch 7.4.004
d6ba96
Problem:    When closing a window fails ":bwipe" may hang.
d6ba96
Solution:   Let win_close() return FAIL and break out of the loop.
d6ba96
Files:	    src/window.c, src/proto/window.pro, src/buffer.c
d6ba96
d6ba96
d6ba96
*** ../vim-7.4.003/src/window.c	2013-07-24 17:38:29.000000000 +0200
d6ba96
--- src/window.c	2013-08-14 16:52:44.000000000 +0200
d6ba96
***************
d6ba96
*** 2172,2179 ****
d6ba96
   * If "free_buf" is TRUE related buffer may be unloaded.
d6ba96
   *
d6ba96
   * Called by :quit, :close, :xit, :wq and findtag().
d6ba96
   */
d6ba96
!     void
d6ba96
  win_close(win, free_buf)
d6ba96
      win_T	*win;
d6ba96
      int		free_buf;
d6ba96
--- 2172,2180 ----
d6ba96
   * If "free_buf" is TRUE related buffer may be unloaded.
d6ba96
   *
d6ba96
   * Called by :quit, :close, :xit, :wq and findtag().
d6ba96
+  * Returns FAIL when the window was not closed.
d6ba96
   */
d6ba96
!     int
d6ba96
  win_close(win, free_buf)
d6ba96
      win_T	*win;
d6ba96
      int		free_buf;
d6ba96
***************
d6ba96
*** 2190,2210 ****
d6ba96
      if (last_window())
d6ba96
      {
d6ba96
  	EMSG(_("E444: Cannot close last window"));
d6ba96
! 	return;
d6ba96
      }
d6ba96
  
d6ba96
  #ifdef FEAT_AUTOCMD
d6ba96
      if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_closing))
d6ba96
! 	return; /* window is already being closed */
d6ba96
      if (win == aucmd_win)
d6ba96
      {
d6ba96
  	EMSG(_("E813: Cannot close autocmd window"));
d6ba96
! 	return;
d6ba96
      }
d6ba96
      if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window())
d6ba96
      {
d6ba96
  	EMSG(_("E814: Cannot close window, only autocmd window would remain"));
d6ba96
! 	return;
d6ba96
      }
d6ba96
  #endif
d6ba96
  
d6ba96
--- 2191,2211 ----
d6ba96
      if (last_window())
d6ba96
      {
d6ba96
  	EMSG(_("E444: Cannot close last window"));
d6ba96
! 	return FAIL;
d6ba96
      }
d6ba96
  
d6ba96
  #ifdef FEAT_AUTOCMD
d6ba96
      if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_closing))
d6ba96
! 	return FAIL; /* window is already being closed */
d6ba96
      if (win == aucmd_win)
d6ba96
      {
d6ba96
  	EMSG(_("E813: Cannot close autocmd window"));
d6ba96
! 	return FAIL;
d6ba96
      }
d6ba96
      if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window())
d6ba96
      {
d6ba96
  	EMSG(_("E814: Cannot close window, only autocmd window would remain"));
d6ba96
! 	return FAIL;
d6ba96
      }
d6ba96
  #endif
d6ba96
  
d6ba96
***************
d6ba96
*** 2212,2218 ****
d6ba96
       * and then close the window and the tab page to avoid that curwin and
d6ba96
       * curtab are invalid while we are freeing memory. */
d6ba96
      if (close_last_window_tabpage(win, free_buf, prev_curtab))
d6ba96
!       return;
d6ba96
  
d6ba96
      /* When closing the help window, try restoring a snapshot after closing
d6ba96
       * the window.  Otherwise clear the snapshot, it's now invalid. */
d6ba96
--- 2213,2219 ----
d6ba96
       * and then close the window and the tab page to avoid that curwin and
d6ba96
       * curtab are invalid while we are freeing memory. */
d6ba96
      if (close_last_window_tabpage(win, free_buf, prev_curtab))
d6ba96
!       return FAIL;
d6ba96
  
d6ba96
      /* When closing the help window, try restoring a snapshot after closing
d6ba96
       * the window.  Otherwise clear the snapshot, it's now invalid. */
d6ba96
***************
d6ba96
*** 2240,2261 ****
d6ba96
  	    win->w_closing = TRUE;
d6ba96
  	    apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf);
d6ba96
  	    if (!win_valid(win))
d6ba96
! 		return;
d6ba96
  	    win->w_closing = FALSE;
d6ba96
  	    if (last_window())
d6ba96
! 		return;
d6ba96
  	}
d6ba96
  	win->w_closing = TRUE;
d6ba96
  	apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf);
d6ba96
  	if (!win_valid(win))
d6ba96
! 	    return;
d6ba96
  	win->w_closing = FALSE;
d6ba96
  	if (last_window())
d6ba96
! 	    return;
d6ba96
  # ifdef FEAT_EVAL
d6ba96
  	/* autocmds may abort script processing */
d6ba96
  	if (aborting())
d6ba96
! 	    return;
d6ba96
  # endif
d6ba96
      }
d6ba96
  #endif
d6ba96
--- 2241,2262 ----
d6ba96
  	    win->w_closing = TRUE;
d6ba96
  	    apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf);
d6ba96
  	    if (!win_valid(win))
d6ba96
! 		return FAIL;
d6ba96
  	    win->w_closing = FALSE;
d6ba96
  	    if (last_window())
d6ba96
! 		return FAIL;
d6ba96
  	}
d6ba96
  	win->w_closing = TRUE;
d6ba96
  	apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf);
d6ba96
  	if (!win_valid(win))
d6ba96
! 	    return FAIL;
d6ba96
  	win->w_closing = FALSE;
d6ba96
  	if (last_window())
d6ba96
! 	    return FAIL;
d6ba96
  # ifdef FEAT_EVAL
d6ba96
  	/* autocmds may abort script processing */
d6ba96
  	if (aborting())
d6ba96
! 	    return FAIL;
d6ba96
  # endif
d6ba96
      }
d6ba96
  #endif
d6ba96
***************
d6ba96
*** 2303,2309 ****
d6ba96
       * other window or moved to another tab page. */
d6ba96
      else if (!win_valid(win) || last_window() || curtab != prev_curtab
d6ba96
  	    || close_last_window_tabpage(win, free_buf, prev_curtab))
d6ba96
! 	return;
d6ba96
  
d6ba96
      /* Free the memory used for the window and get the window that received
d6ba96
       * the screen space. */
d6ba96
--- 2304,2310 ----
d6ba96
       * other window or moved to another tab page. */
d6ba96
      else if (!win_valid(win) || last_window() || curtab != prev_curtab
d6ba96
  	    || close_last_window_tabpage(win, free_buf, prev_curtab))
d6ba96
! 	return FAIL;
d6ba96
  
d6ba96
      /* Free the memory used for the window and get the window that received
d6ba96
       * the screen space. */
d6ba96
***************
d6ba96
*** 2383,2388 ****
d6ba96
--- 2384,2390 ----
d6ba96
  #endif
d6ba96
  
d6ba96
      redraw_all_later(NOT_VALID);
d6ba96
+     return OK;
d6ba96
  }
d6ba96
  
d6ba96
  /*
d6ba96
*** ../vim-7.4.003/src/proto/window.pro	2013-08-10 13:37:30.000000000 +0200
d6ba96
--- src/proto/window.pro	2013-08-14 16:52:50.000000000 +0200
d6ba96
***************
d6ba96
*** 9,15 ****
d6ba96
  void win_equal __ARGS((win_T *next_curwin, int current, int dir));
d6ba96
  void close_windows __ARGS((buf_T *buf, int keep_curwin));
d6ba96
  int one_window __ARGS((void));
d6ba96
! void win_close __ARGS((win_T *win, int free_buf));
d6ba96
  void win_close_othertab __ARGS((win_T *win, int free_buf, tabpage_T *tp));
d6ba96
  void win_free_all __ARGS((void));
d6ba96
  win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
d6ba96
--- 9,15 ----
d6ba96
  void win_equal __ARGS((win_T *next_curwin, int current, int dir));
d6ba96
  void close_windows __ARGS((buf_T *buf, int keep_curwin));
d6ba96
  int one_window __ARGS((void));
d6ba96
! int win_close __ARGS((win_T *win, int free_buf));
d6ba96
  void win_close_othertab __ARGS((win_T *win, int free_buf, tabpage_T *tp));
d6ba96
  void win_free_all __ARGS((void));
d6ba96
  win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
d6ba96
*** ../vim-7.4.003/src/buffer.c	2013-07-17 16:39:00.000000000 +0200
d6ba96
--- src/buffer.c	2013-08-14 16:54:34.000000000 +0200
d6ba96
***************
d6ba96
*** 1186,1192 ****
d6ba96
  		   && !(curwin->w_closing || curwin->w_buffer->b_closing)
d6ba96
  # endif
d6ba96
  		   && (firstwin != lastwin || first_tabpage->tp_next != NULL))
d6ba96
! 	    win_close(curwin, FALSE);
d6ba96
  #endif
d6ba96
  
d6ba96
  	/*
d6ba96
--- 1186,1195 ----
d6ba96
  		   && !(curwin->w_closing || curwin->w_buffer->b_closing)
d6ba96
  # endif
d6ba96
  		   && (firstwin != lastwin || first_tabpage->tp_next != NULL))
d6ba96
! 	{
d6ba96
! 	    if (win_close(curwin, FALSE) == FAIL)
d6ba96
! 		break;
d6ba96
! 	}
d6ba96
  #endif
d6ba96
  
d6ba96
  	/*
d6ba96
*** ../vim-7.4.003/src/version.c	2013-08-14 14:18:37.000000000 +0200
d6ba96
--- src/version.c	2013-08-14 17:10:23.000000000 +0200
d6ba96
***************
d6ba96
*** 729,730 ****
d6ba96
--- 729,732 ----
d6ba96
  {   /* Add new patch number below this line */
d6ba96
+ /**/
d6ba96
+     4,
d6ba96
  /**/
d6ba96
d6ba96
-- 
d6ba96
From "know your smileys":
d6ba96
 *<|:-)	Santa Claus (Ho Ho Ho)
d6ba96
d6ba96
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
d6ba96
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
d6ba96
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
d6ba96
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///