0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

updated for version 7.4.004

Problem:    When closing a window fails ":bwipe" may hang.
Solution:   Let win_close() return FAIL and break out of the loop.
This commit is contained in:
Bram Moolenaar
2013-08-14 17:11:20 +02:00
parent ebefd997bb
commit c93df6b075
4 changed files with 21 additions and 14 deletions

View File

@@ -1186,7 +1186,10 @@ do_buffer(action, start, dir, count, forceit)
&& !(curwin->w_closing || curwin->w_buffer->b_closing) && !(curwin->w_closing || curwin->w_buffer->b_closing)
# endif # endif
&& (firstwin != lastwin || first_tabpage->tp_next != NULL)) && (firstwin != lastwin || first_tabpage->tp_next != NULL))
win_close(curwin, FALSE); {
if (win_close(curwin, FALSE) == FAIL)
break;
}
#endif #endif
/* /*

View File

@@ -9,7 +9,7 @@ void win_move_after __ARGS((win_T *win1, win_T *win2));
void win_equal __ARGS((win_T *next_curwin, int current, int dir)); void win_equal __ARGS((win_T *next_curwin, int current, int dir));
void close_windows __ARGS((buf_T *buf, int keep_curwin)); void close_windows __ARGS((buf_T *buf, int keep_curwin));
int one_window __ARGS((void)); int one_window __ARGS((void));
void win_close __ARGS((win_T *win, int free_buf)); int win_close __ARGS((win_T *win, int free_buf));
void win_close_othertab __ARGS((win_T *win, int free_buf, tabpage_T *tp)); void win_close_othertab __ARGS((win_T *win, int free_buf, tabpage_T *tp));
void win_free_all __ARGS((void)); void win_free_all __ARGS((void));
win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp)); win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));

View File

@@ -727,6 +727,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4,
/**/ /**/
3, 3,
/**/ /**/

View File

@@ -2172,8 +2172,9 @@ close_last_window_tabpage(win, free_buf, prev_curtab)
* If "free_buf" is TRUE related buffer may be unloaded. * If "free_buf" is TRUE related buffer may be unloaded.
* *
* Called by :quit, :close, :xit, :wq and findtag(). * Called by :quit, :close, :xit, :wq and findtag().
* Returns FAIL when the window was not closed.
*/ */
void int
win_close(win, free_buf) win_close(win, free_buf)
win_T *win; win_T *win;
int free_buf; int free_buf;
@@ -2190,21 +2191,21 @@ win_close(win, free_buf)
if (last_window()) if (last_window())
{ {
EMSG(_("E444: Cannot close last window")); EMSG(_("E444: Cannot close last window"));
return; return FAIL;
} }
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_closing)) if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_closing))
return; /* window is already being closed */ return FAIL; /* window is already being closed */
if (win == aucmd_win) if (win == aucmd_win)
{ {
EMSG(_("E813: Cannot close autocmd window")); EMSG(_("E813: Cannot close autocmd window"));
return; return FAIL;
} }
if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window()) if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window())
{ {
EMSG(_("E814: Cannot close window, only autocmd window would remain")); EMSG(_("E814: Cannot close window, only autocmd window would remain"));
return; return FAIL;
} }
#endif #endif
@@ -2212,7 +2213,7 @@ win_close(win, free_buf)
* and then close the window and the tab page to avoid that curwin and * and then close the window and the tab page to avoid that curwin and
* curtab are invalid while we are freeing memory. */ * curtab are invalid while we are freeing memory. */
if (close_last_window_tabpage(win, free_buf, prev_curtab)) if (close_last_window_tabpage(win, free_buf, prev_curtab))
return; return FAIL;
/* When closing the help window, try restoring a snapshot after closing /* When closing the help window, try restoring a snapshot after closing
* the window. Otherwise clear the snapshot, it's now invalid. */ * the window. Otherwise clear the snapshot, it's now invalid. */
@@ -2240,22 +2241,22 @@ win_close(win, free_buf)
win->w_closing = TRUE; win->w_closing = TRUE;
apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf);
if (!win_valid(win)) if (!win_valid(win))
return; return FAIL;
win->w_closing = FALSE; win->w_closing = FALSE;
if (last_window()) if (last_window())
return; return FAIL;
} }
win->w_closing = TRUE; win->w_closing = TRUE;
apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf);
if (!win_valid(win)) if (!win_valid(win))
return; return FAIL;
win->w_closing = FALSE; win->w_closing = FALSE;
if (last_window()) if (last_window())
return; return FAIL;
# ifdef FEAT_EVAL # ifdef FEAT_EVAL
/* autocmds may abort script processing */ /* autocmds may abort script processing */
if (aborting()) if (aborting())
return; return FAIL;
# endif # endif
} }
#endif #endif
@@ -2303,7 +2304,7 @@ win_close(win, free_buf)
* other window or moved to another tab page. */ * other window or moved to another tab page. */
else if (!win_valid(win) || last_window() || curtab != prev_curtab else if (!win_valid(win) || last_window() || curtab != prev_curtab
|| close_last_window_tabpage(win, free_buf, prev_curtab)) || close_last_window_tabpage(win, free_buf, prev_curtab))
return; return FAIL;
/* Free the memory used for the window and get the window that received /* Free the memory used for the window and get the window that received
* the screen space. */ * the screen space. */
@@ -2383,6 +2384,7 @@ win_close(win, free_buf)
#endif #endif
redraw_all_later(NOT_VALID); redraw_all_later(NOT_VALID);
return OK;
} }
/* /*