Mercurial > vim
comparison src/window.c @ 10106:58e6dd1d8be3 v7.4.2324
commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Sep 4 19:50:54 2016 +0200
patch 7.4.2324
Problem: Crash when editing a new buffer and BufUnload autocommand wipes
out the new buffer. (Norio Takagi)
Solution: Don't allow wiping out this buffer. (partly by Hirohito Higashi)
Move old style test13 into test_autocmd. Avoid ml_get error when
editing a file.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 04 Sep 2016 20:00:07 +0200 |
parents | 7fc6103c6651 |
children | cf988222b150 |
comparison
equal
deleted
inserted
replaced
10105:5aca505bbcfe | 10106:58e6dd1d8be3 |
---|---|
2125 | 2125 |
2126 for (wp = firstwin; wp != NULL && lastwin != firstwin; ) | 2126 for (wp = firstwin; wp != NULL && lastwin != firstwin; ) |
2127 { | 2127 { |
2128 if (wp->w_buffer == buf && (!keep_curwin || wp != curwin) | 2128 if (wp->w_buffer == buf && (!keep_curwin || wp != curwin) |
2129 #ifdef FEAT_AUTOCMD | 2129 #ifdef FEAT_AUTOCMD |
2130 && !(wp->w_closing || wp->w_buffer->b_closing) | 2130 && !(wp->w_closing || wp->w_buffer->b_locked > 0) |
2131 #endif | 2131 #endif |
2132 ) | 2132 ) |
2133 { | 2133 { |
2134 win_close(wp, FALSE); | 2134 win_close(wp, FALSE); |
2135 | 2135 |
2146 nexttp = tp->tp_next; | 2146 nexttp = tp->tp_next; |
2147 if (tp != curtab) | 2147 if (tp != curtab) |
2148 for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) | 2148 for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) |
2149 if (wp->w_buffer == buf | 2149 if (wp->w_buffer == buf |
2150 #ifdef FEAT_AUTOCMD | 2150 #ifdef FEAT_AUTOCMD |
2151 && !(wp->w_closing || wp->w_buffer->b_closing) | 2151 && !(wp->w_closing || wp->w_buffer->b_locked > 0) |
2152 #endif | 2152 #endif |
2153 ) | 2153 ) |
2154 { | 2154 { |
2155 win_close_othertab(wp, FALSE, tp); | 2155 win_close_othertab(wp, FALSE, tp); |
2156 | 2156 |
2285 EMSG(_("E444: Cannot close last window")); | 2285 EMSG(_("E444: Cannot close last window")); |
2286 return FAIL; | 2286 return FAIL; |
2287 } | 2287 } |
2288 | 2288 |
2289 #ifdef FEAT_AUTOCMD | 2289 #ifdef FEAT_AUTOCMD |
2290 if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_closing)) | 2290 if (win->w_closing || (win->w_buffer != NULL |
2291 && win->w_buffer->b_locked > 0)) | |
2291 return FAIL; /* window is already being closed */ | 2292 return FAIL; /* window is already being closed */ |
2292 if (win == aucmd_win) | 2293 if (win == aucmd_win) |
2293 { | 2294 { |
2294 EMSG(_("E813: Cannot close autocmd window")); | 2295 EMSG(_("E813: Cannot close autocmd window")); |
2295 return FAIL; | 2296 return FAIL; |
2501 int free_tp = FALSE; | 2502 int free_tp = FALSE; |
2502 | 2503 |
2503 #ifdef FEAT_AUTOCMD | 2504 #ifdef FEAT_AUTOCMD |
2504 /* Get here with win->w_buffer == NULL when win_close() detects the tab | 2505 /* Get here with win->w_buffer == NULL when win_close() detects the tab |
2505 * page changed. */ | 2506 * page changed. */ |
2506 if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_closing)) | 2507 if (win->w_closing || (win->w_buffer != NULL |
2508 && win->w_buffer->b_locked > 0)) | |
2507 return; /* window is already being closed */ | 2509 return; /* window is already being closed */ |
2508 #endif | 2510 #endif |
2509 | 2511 |
2510 if (win->w_buffer != NULL) | 2512 if (win->w_buffer != NULL) |
2511 /* Close the link to the buffer. */ | 2513 /* Close the link to the buffer. */ |