summaryrefslogtreecommitdiffstats
path: root/src/popupwin.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-06-20 03:45:36 +0200
committerBram Moolenaar <Bram@vim.org>2019-06-20 03:45:36 +0200
commit75a1a9415b9c207de5a29b25c0d1949c6c9c5c61 (patch)
tree470a0887aed4e52e342edbca555e0bec1b85af99 /src/popupwin.c
parenta3fce62c911c204ae144b55018f6dc9295088850 (diff)
patch 8.1.1575: callbacks may be garbage collectedv8.1.1575
Problem: Callbacks may be garbage collected. Solution: Set reference in callbacks. (Ozaki Kiichi, closes #4564)
Diffstat (limited to 'src/popupwin.c')
-rw-r--r--src/popupwin.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index e1fc0a7f42..b6bb593ea9 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -2140,4 +2140,50 @@ update_popups(void (*win_update)(win_T *wp))
}
}
+/*
+ * 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