Mercurial > vim
diff src/popupwin.c @ 17151:ebe9aab81898 v8.1.1575
patch 8.1.1575: callbacks may be garbage collected
commit https://github.com/vim/vim/commit/75a1a9415b9c207de5a29b25c0d1949c6c9c5c61
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 20 03:45:36 2019 +0200
patch 8.1.1575: callbacks may be garbage collected
Problem: Callbacks may be garbage collected.
Solution: Set reference in callbacks. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/4564)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 20 Jun 2019 04:00:07 +0200 |
parents | c90fdb999393 |
children | f16cee6adf29 |
line wrap: on
line diff
--- a/src/popupwin.c +++ b/src/popupwin.c @@ -2140,4 +2140,50 @@ update_popups(void (*win_update)(win_T * } } +/* + * Mark references in callbacks of one popup window. + */ + static int +set_ref_in_one_popup(win_T *wp, int copyID) +{ + int abort = FALSE; + typval_T tv; + + if (wp->w_close_cb.cb_partial != NULL) + { + tv.v_type = VAR_PARTIAL; + tv.vval.v_partial = wp->w_close_cb.cb_partial; + abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); + } + if (wp->w_filter_cb.cb_partial != NULL) + { + tv.v_type = VAR_PARTIAL; + tv.vval.v_partial = wp->w_filter_cb.cb_partial; + abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); + } + return abort; +} + +/* + * Set reference in callbacks of popup windows. + */ + int +set_ref_in_popups(int copyID) +{ + int abort = FALSE; + win_T *wp; + tabpage_T *tp; + + for (wp = first_popupwin; !abort && wp != NULL; wp = wp->w_next) + abort = abort || set_ref_in_one_popup(wp, copyID); + + FOR_ALL_TABPAGES(tp) + { + for (wp = tp->tp_first_popupwin; !abort && wp != NULL; wp = wp->w_next) + abort = abort || set_ref_in_one_popup(wp, copyID); + if (abort) + break; + } + return abort; +} #endif // FEAT_TEXT_PROP