1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: When closing a window there is a chance that deleting a scrollbar
12 triggers a GUI resize, which uses the window while it is not in a
14 Solution: Set the buffer pointer to NULL to be able to detect the invalid
15 situation. Fix a few places that used the buffer pointer
17 Files: src/buffer.c, src/ex_cmds.c, src/term.c, src/window.c
20 *** ../vim-7.3.305/src/buffer.c 2011-05-19 13:40:47.000000000 +0200
21 --- src/buffer.c 2011-09-10 13:46:59.000000000 +0200
27 buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0));
28 + if (win_valid(win) && win->w_buffer == buf)
29 + win->w_buffer = NULL; /* make sure we don't use the buffer now */
32 /* Autocommands may have deleted the buffer. */
37 diff_buf_delete(buf); /* Can't use 'diff' for unloaded buffer. */
40 + if (curwin->w_buffer == buf)
41 + reset_synblock(curwin); /* remove any ownsyntax */
45 /* No folds in an empty buffer. */
53 + if (prevbuf == curwin->w_buffer)
54 + reset_synblock(curwin);
58 close_windows(prevbuf, FALSE);
61 foldUpdateAll(curwin); /* update folds (later). */
65 - reset_synblock(curwin);
66 - curwin->w_s = &(buf->b_s);
68 /* Get the buffer in the current window. */
69 curwin->w_buffer = buf;
79 + curwin->w_s = &(buf->b_s);
82 /* Cursor on first line by default. */
83 curwin->w_cursor.lnum = 1;
84 curwin->w_cursor.col = 0;
85 *** ../vim-7.3.305/src/ex_cmds.c 2011-07-07 16:20:45.000000000 +0200
86 --- src/ex_cmds.c 2011-09-10 13:39:13.000000000 +0200
90 check_arg_idx(curwin);
93 - reset_synblock(curwin); /* remove any ownsyntax */
100 *** ../vim-7.3.305/src/term.c 2011-05-10 16:41:13.000000000 +0200
101 --- src/term.c 2011-09-14 14:39:39.000000000 +0200
104 if (width < 0 || height < 0) /* just checking... */
107 ! if (State == HITRETURN || State == SETWSIZE) /* postpone the resizing */
117 if (width < 0 || height < 0) /* just checking... */
120 ! if (State == HITRETURN || State == SETWSIZE)
122 + /* postpone the resizing */
127 + /* curwin->w_buffer can be NULL when we are closing a window and the
128 + * buffer has already been closed and removing a scrollbar causes a resize
129 + * event. Don't resize then, it will happen after entering another buffer.
131 + if (curwin->w_buffer == NULL)
137 *** ../vim-7.3.305/src/window.c 2011-01-08 14:45:57.000000000 +0100
138 --- src/window.c 2011-09-10 14:04:56.000000000 +0200
142 newp->w_tagstackidx = oldp->w_tagstackidx;
143 newp->w_tagstacklen = oldp->w_tagstacklen;
144 ! # ifdef FEAT_FOLDING
145 copyFoldingState(oldp, newp);
148 win_init_some(newp, oldp);
150 ! # ifdef FEAT_SYN_HL
151 check_colorcolumn(newp);
158 newp->w_tagstackidx = oldp->w_tagstackidx;
159 newp->w_tagstacklen = oldp->w_tagstacklen;
160 ! #ifdef FEAT_FOLDING
161 copyFoldingState(oldp, newp);
164 win_init_some(newp, oldp);
167 check_colorcolumn(newp);
179 + /* Free independent synblock before the buffer is freed. */
180 + reset_synblock(win);
184 * Close the link to the buffer.
188 if (!win_valid(win) || last_window() || curtab != prev_curtab)
191 ! /* Free the memory used for the window. */
192 wp = win_free_mem(win, &dir, NULL);
194 /* Make sure curwin isn't invalid. It can cause severe trouble when
196 if (!win_valid(win) || last_window() || curtab != prev_curtab)
199 ! /* Free the memory used for the window and get the window that received
200 ! * the screen space. */
201 wp = win_free_mem(win, &dir, NULL);
203 /* Make sure curwin isn't invalid. It can cause severe trouble when
208 wp->w_farsi = W_CONV;
211 + wp->w_s = &wp->w_buffer->b_s;
218 #endif /* FEAT_GUI */
221 - reset_synblock(wp); /* free independent synblock */
222 vim_free(wp->w_p_cc_cols);
226 *** ../vim-7.3.305/src/version.c 2011-09-14 14:33:47.000000000 +0200
227 --- src/version.c 2011-09-14 14:35:30.000000000 +0200
231 { /* Add new patch number below this line */
237 A consultant is a person who takes your money and annoys your employees while
238 tirelessly searching for the best way to extend the consulting contract.
239 (Scott Adams - The Dilbert principle)
241 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
242 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
243 \\\ an exciting new programming language -- http://www.Zimbu.org ///
244 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///