Skip to content

Commit aedeb42

Browse files
committed
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.
1 parent 00534f3 commit aedeb42

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

src/buffer.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,10 @@ do_buffer(action, start, dir, count, forceit)
11861186
&& !(curwin->w_closing || curwin->w_buffer->b_closing)
11871187
# endif
11881188
&& (firstwin != lastwin || first_tabpage->tp_next != NULL))
1189-
win_close(curwin, FALSE);
1189+
{
1190+
if (win_close(curwin, FALSE) == FAIL)
1191+
break;
1192+
}
11901193
#endif
11911194

11921195
/*

src/proto/window.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void win_move_after __ARGS((win_T *win1, win_T *win2));
99
void win_equal __ARGS((win_T *next_curwin, int current, int dir));
1010
void close_windows __ARGS((buf_T *buf, int keep_curwin));
1111
int one_window __ARGS((void));
12-
void win_close __ARGS((win_T *win, int free_buf));
12+
int win_close __ARGS((win_T *win, int free_buf));
1313
void win_close_othertab __ARGS((win_T *win, int free_buf, tabpage_T *tp));
1414
void win_free_all __ARGS((void));
1515
win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,8 @@ static char *(features[]) =
727727

728728
static int included_patches[] =
729729
{ /* Add new patch number below this line */
730+
/**/
731+
4,
730732
/**/
731733
3,
732734
/**/

src/window.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,8 +2172,9 @@ close_last_window_tabpage(win, free_buf, prev_curtab)
21722172
* If "free_buf" is TRUE related buffer may be unloaded.
21732173
*
21742174
* Called by :quit, :close, :xit, :wq and findtag().
2175+
* Returns FAIL when the window was not closed.
21752176
*/
2176-
void
2177+
int
21772178
win_close(win, free_buf)
21782179
win_T *win;
21792180
int free_buf;
@@ -2190,29 +2191,29 @@ win_close(win, free_buf)
21902191
if (last_window())
21912192
{
21922193
EMSG(_("E444: Cannot close last window"));
2193-
return;
2194+
return FAIL;
21942195
}
21952196

21962197
#ifdef FEAT_AUTOCMD
21972198
if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_closing))
2198-
return; /* window is already being closed */
2199+
return FAIL; /* window is already being closed */
21992200
if (win == aucmd_win)
22002201
{
22012202
EMSG(_("E813: Cannot close autocmd window"));
2202-
return;
2203+
return FAIL;
22032204
}
22042205
if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window())
22052206
{
22062207
EMSG(_("E814: Cannot close window, only autocmd window would remain"));
2207-
return;
2208+
return FAIL;
22082209
}
22092210
#endif
22102211

22112212
/* When closing the last window in a tab page first go to another tab page
22122213
* and then close the window and the tab page to avoid that curwin and
22132214
* curtab are invalid while we are freeing memory. */
22142215
if (close_last_window_tabpage(win, free_buf, prev_curtab))
2215-
return;
2216+
return FAIL;
22162217

22172218
/* When closing the help window, try restoring a snapshot after closing
22182219
* the window. Otherwise clear the snapshot, it's now invalid. */
@@ -2240,22 +2241,22 @@ win_close(win, free_buf)
22402241
win->w_closing = TRUE;
22412242
apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf);
22422243
if (!win_valid(win))
2243-
return;
2244+
return FAIL;
22442245
win->w_closing = FALSE;
22452246
if (last_window())
2246-
return;
2247+
return FAIL;
22472248
}
22482249
win->w_closing = TRUE;
22492250
apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf);
22502251
if (!win_valid(win))
2251-
return;
2252+
return FAIL;
22522253
win->w_closing = FALSE;
22532254
if (last_window())
2254-
return;
2255+
return FAIL;
22552256
# ifdef FEAT_EVAL
22562257
/* autocmds may abort script processing */
22572258
if (aborting())
2258-
return;
2259+
return FAIL;
22592260
# endif
22602261
}
22612262
#endif
@@ -2303,7 +2304,7 @@ win_close(win, free_buf)
23032304
* other window or moved to another tab page. */
23042305
else if (!win_valid(win) || last_window() || curtab != prev_curtab
23052306
|| close_last_window_tabpage(win, free_buf, prev_curtab))
2306-
return;
2307+
return FAIL;
23072308

23082309
/* Free the memory used for the window and get the window that received
23092310
* the screen space. */
@@ -2383,6 +2384,7 @@ win_close(win, free_buf)
23832384
#endif
23842385

23852386
redraw_all_later(NOT_VALID);
2387+
return OK;
23862388
}
23872389

23882390
/*

0 commit comments

Comments
 (0)