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: Crash when closing last window in a tab. (Alex Efros)
12 Solution: Use common code in close_last_window_tabpage(). (Christian
17 *** ../vim-7.3.527/src/window.c 2012-03-16 19:07:54.000000000 +0100
18 --- src/window.c 2012-05-25 12:25:16.000000000 +0200
22 static void win_totop __ARGS((int size, int flags));
23 static void win_equal_rec __ARGS((win_T *next_curwin, int current, frame_T *topfr, int dir, int col, int row, int width, int height));
24 static int last_window __ARGS((void));
25 + static int close_last_window_tabpage __ARGS((win_T *win, int free_buf, tabpage_T *prev_curtab));
26 static win_T *win_free_mem __ARGS((win_T *win, int *dirp, tabpage_T *tp));
27 static frame_T *win_altframe __ARGS((win_T *win, tabpage_T *tp));
28 static tabpage_T *alt_tabpage __ARGS((void));
35 + * Close the possibly last window in a tab page.
36 + * Returns TRUE when the window was closed already.
39 + close_last_window_tabpage(win, free_buf, prev_curtab)
42 + tabpage_T *prev_curtab;
44 + if (firstwin == lastwin)
47 + * Closing the last window in a tab page. First go to another tab
48 + * page and then close the window and the tab page. This avoids that
49 + * curwin and curtab are invalid while we are freeing memory, they may
50 + * be used in GUI events.
52 + goto_tabpage_tp(alt_tabpage());
53 + redraw_tabline = TRUE;
55 + /* Safety check: Autocommands may have closed the window when jumping
56 + * to the other tab page. */
57 + if (valid_tabpage(prev_curtab) && prev_curtab->tp_firstwin == win)
59 + int h = tabline_height();
61 + win_close_othertab(win, free_buf, prev_curtab);
62 + if (h != tabline_height())
71 * Close window "win". Only works for the current tab page.
72 * If "free_buf" is TRUE related buffer may be unloaded.
80 ! * When closing the last window in a tab page first go to another tab
81 ! * page and then close the window and the tab page. This avoids that
82 ! * curwin and curtab are not invalid while we are freeing memory, they may
83 ! * be used in GUI events.
85 ! if (firstwin == lastwin)
87 ! goto_tabpage_tp(alt_tabpage());
88 ! redraw_tabline = TRUE;
90 ! /* Safety check: Autocommands may have closed the window when jumping
91 ! * to the other tab page. */
92 ! if (valid_tabpage(prev_curtab) && prev_curtab->tp_firstwin == win)
94 ! int h = tabline_height();
96 ! win_close_othertab(win, free_buf, prev_curtab);
97 ! if (h != tabline_height())
103 /* When closing the help window, try restoring a snapshot after closing
104 * the window. Otherwise clear the snapshot, it's now invalid. */
109 ! /* When closing the last window in a tab page first go to another tab page
110 ! * and then close the window and the tab page to avoid that curwin and
111 ! * curtab are invalid while we are freeing memory. */
112 ! if (close_last_window_tabpage(win, free_buf, prev_curtab))
115 /* When closing the help window, try restoring a snapshot after closing
116 * the window. Otherwise clear the snapshot, it's now invalid. */
120 /* Autocommands may have closed the window already, or closed the only
121 * other window or moved to another tab page. */
122 ! if (!win_valid(win) || last_window() || curtab != prev_curtab)
125 /* Free the memory used for the window and get the window that received
128 /* Autocommands may have closed the window already, or closed the only
129 * other window or moved to another tab page. */
130 ! if (!win_valid(win) || last_window() || curtab != prev_curtab
131 ! || close_last_window_tabpage(win, free_buf, prev_curtab))
134 /* Free the memory used for the window and get the window that received
139 * Close window "win" in tab page "tp", which is not the current tab page.
140 ! * This may be the last window ih that tab page and result in closing the tab,
141 * thus "tp" may become invalid!
142 * Caller must check if buffer is hidden and whether the tabline needs to be
147 * Close window "win" in tab page "tp", which is not the current tab page.
148 ! * This may be the last window in that tab page and result in closing the tab,
149 * thus "tp" may become invalid!
150 * Caller must check if buffer is hidden and whether the tabline needs to be
152 *** ../vim-7.3.527/src/version.c 2012-05-25 11:56:06.000000000 +0200
153 --- src/version.c 2012-05-25 12:38:25.000000000 +0200
157 { /* Add new patch number below this line */
163 For society, it's probably a good thing that engineers value function over
164 appearance. For example, you wouldn't want engineers to build nuclear power
165 plants that only _look_ like they would keep all the radiation inside.
166 (Scott Adams - The Dilbert principle)
168 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
169 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
170 \\\ an exciting new programming language -- http://www.Zimbu.org ///
171 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///