comparison src/popupwin.c @ 19117:8db080710015 v8.2.0118

patch 8.2.0118: crash when cycling to buffers involving popup window Commit: https://github.com/vim/vim/commit/ca7c078b799bfc96b54e9e41f5be3e0bfefadce5 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 14 20:42:48 2020 +0100 patch 8.2.0118: crash when cycling to buffers involving popup window Problem: Crash when cycling to buffers involving popup window . Solution: Do not decrement buffer reference count.
author Bram Moolenaar <Bram@vim.org>
date Tue, 14 Jan 2020 20:45:04 +0100
parents 48e0208f53c2
children 215793f6b59d
comparison
equal deleted inserted replaced
19116:9b7f90e56753 19117:8db080710015
935 apply_move_options(wp, dict); 935 apply_move_options(wp, dict);
936 apply_general_options(wp, dict); 936 apply_general_options(wp, dict);
937 937
938 nr = dict_get_number(dict, (char_u *)"hidden"); 938 nr = dict_get_number(dict, (char_u *)"hidden");
939 if (nr > 0) 939 if (nr > 0)
940 {
941 wp->w_popup_flags |= POPF_HIDDEN; 940 wp->w_popup_flags |= POPF_HIDDEN;
942 --wp->w_buffer->b_nwindows;
943 }
944 941
945 popup_mask_refresh = TRUE; 942 popup_mask_refresh = TRUE;
946 popup_highlight_curline(wp); 943 popup_highlight_curline(wp);
947 } 944 }
948 945
1151 // Text property is no longer visible, hide the popup. 1148 // Text property is no longer visible, hide the popup.
1152 // Unhiding the popup is done in check_popup_unhidden(). 1149 // Unhiding the popup is done in check_popup_unhidden().
1153 if ((wp->w_popup_flags & POPF_HIDDEN) == 0) 1150 if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
1154 { 1151 {
1155 wp->w_popup_flags |= POPF_HIDDEN; 1152 wp->w_popup_flags |= POPF_HIDDEN;
1156 --wp->w_buffer->b_nwindows;
1157 if (win_valid(wp->w_popup_prop_win)) 1153 if (win_valid(wp->w_popup_prop_win))
1158 redraw_win_later(wp->w_popup_prop_win, SOME_VALID); 1154 redraw_win_later(wp->w_popup_prop_win, SOME_VALID);
1159 } 1155 }
1160 return; 1156 return;
1161 } 1157 }
2349 popup_hide(win_T *wp) 2345 popup_hide(win_T *wp)
2350 { 2346 {
2351 if ((wp->w_popup_flags & POPF_HIDDEN) == 0) 2347 if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
2352 { 2348 {
2353 wp->w_popup_flags |= POPF_HIDDEN; 2349 wp->w_popup_flags |= POPF_HIDDEN;
2354 --wp->w_buffer->b_nwindows; 2350 // Do not decrement b_nwindows, we still reference the buffer.
2355 redraw_all_later(NOT_VALID); 2351 redraw_all_later(NOT_VALID);
2356 popup_mask_refresh = TRUE; 2352 popup_mask_refresh = TRUE;
2357 } 2353 }
2358 } 2354 }
2359 2355
2374 popup_show(win_T *wp) 2370 popup_show(win_T *wp)
2375 { 2371 {
2376 if ((wp->w_popup_flags & POPF_HIDDEN) != 0) 2372 if ((wp->w_popup_flags & POPF_HIDDEN) != 0)
2377 { 2373 {
2378 wp->w_popup_flags &= ~POPF_HIDDEN; 2374 wp->w_popup_flags &= ~POPF_HIDDEN;
2379 ++wp->w_buffer->b_nwindows;
2380 redraw_all_later(NOT_VALID); 2375 redraw_all_later(NOT_VALID);
2381 popup_mask_refresh = TRUE; 2376 popup_mask_refresh = TRUE;
2382 } 2377 }
2383 } 2378 }
2384 2379
3152 if (find_visible_prop(wp->w_popup_prop_win, 3147 if (find_visible_prop(wp->w_popup_prop_win,
3153 wp->w_popup_prop_type, wp->w_popup_prop_id, 3148 wp->w_popup_prop_type, wp->w_popup_prop_id,
3154 &prop, &lnum) == OK) 3149 &prop, &lnum) == OK)
3155 { 3150 {
3156 wp->w_popup_flags &= ~POPF_HIDDEN; 3151 wp->w_popup_flags &= ~POPF_HIDDEN;
3157 ++wp->w_buffer->b_nwindows;
3158 wp->w_popup_prop_topline = 0; // force repositioning 3152 wp->w_popup_prop_topline = 0; // force repositioning
3159 return TRUE; 3153 return TRUE;
3160 } 3154 }
3161 } 3155 }
3162 return FALSE; 3156 return FALSE;