comparison src/window.c @ 10076:bc30991c3e98 v7.4.2309

commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 2 21:48:32 2016 +0200 patch 7.4.2309 Problem: Crash when doing tabnext in a BufUnload autocmd. (Dominique Pelle) Solution: When detecting that the tab page changed, don't just abort but delete the window where w_buffer is NULL.
author Christian Brabandt <cb@256bit.org>
date Fri, 02 Sep 2016 22:00:07 +0200
parents 4aead6a9b7a9
children 7fc6103c6651
comparison
equal deleted inserted replaced
10075:ee84eb3ac2cc 10076:bc30991c3e98
2377 #ifdef FEAT_AUTOCMD 2377 #ifdef FEAT_AUTOCMD
2378 win->w_closing = TRUE; 2378 win->w_closing = TRUE;
2379 #endif 2379 #endif
2380 close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, TRUE); 2380 close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, TRUE);
2381 #ifdef FEAT_AUTOCMD 2381 #ifdef FEAT_AUTOCMD
2382 if (win_valid(win)) 2382 if (win_valid_any_tab(win))
2383 win->w_closing = FALSE; 2383 win->w_closing = FALSE;
2384 #endif 2384 #endif
2385 /* Make sure curbuf is valid. It can become invalid if 'bufhidden' is 2385 /* Make sure curbuf is valid. It can become invalid if 'bufhidden' is
2386 * "wipe". */ 2386 * "wipe". */
2387 if (!bufref_valid(&bufref)) 2387 if (!bufref_valid(&bufref))
2397 if (curwin->w_buffer == NULL) 2397 if (curwin->w_buffer == NULL)
2398 curwin->w_buffer = curbuf; 2398 curwin->w_buffer = curbuf;
2399 getout(0); 2399 getout(0);
2400 } 2400 }
2401 2401
2402 /* Autocommands may have closed the window already, or closed the only 2402 /* Autocommands may have moved to another tab page. */
2403 * other window or moved to another tab page. */ 2403 if (curtab != prev_curtab && win_valid_any_tab(win)
2404 else if (!win_valid(win) || last_window() || curtab != prev_curtab 2404 && win->w_buffer == NULL)
2405 {
2406 /* Need to close the window anyway, since the buffer is NULL. */
2407 win_close_othertab(win, FALSE, prev_curtab);
2408 return FAIL;
2409 }
2410
2411 /* Autocommands may have closed the window already or closed the only
2412 * other window. */
2413 if (!win_valid(win) || last_window()
2405 || close_last_window_tabpage(win, free_buf, prev_curtab)) 2414 || close_last_window_tabpage(win, free_buf, prev_curtab))
2406 return FAIL; 2415 return FAIL;
2407 2416
2408 /* Free the memory used for the window and get the window that received 2417 /* Free the memory used for the window and get the window that received
2409 * the screen space. */ 2418 * the screen space. */
2490 int dir; 2499 int dir;
2491 tabpage_T *ptp = NULL; 2500 tabpage_T *ptp = NULL;
2492 int free_tp = FALSE; 2501 int free_tp = FALSE;
2493 2502
2494 #ifdef FEAT_AUTOCMD 2503 #ifdef FEAT_AUTOCMD
2495 if (win->w_closing || win->w_buffer->b_closing) 2504 /* Get here with win->w_buffer == NULL when win_close() detects the tab
2505 * page changed. */
2506 if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_closing))
2496 return; /* window is already being closed */ 2507 return; /* window is already being closed */
2497 #endif 2508 #endif
2498 2509
2499 /* Close the link to the buffer. */ 2510 if (win->w_buffer != NULL)
2500 close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, FALSE); 2511 /* Close the link to the buffer. */
2512 close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, FALSE);
2501 2513
2502 /* Careful: Autocommands may have closed the tab page or made it the 2514 /* Careful: Autocommands may have closed the tab page or made it the
2503 * current tab page. */ 2515 * current tab page. */
2504 for (ptp = first_tabpage; ptp != NULL && ptp != tp; ptp = ptp->tp_next) 2516 for (ptp = first_tabpage; ptp != NULL && ptp != tp; ptp = ptp->tp_next)
2505 ; 2517 ;