Mercurial > vim
diff src/channel.c @ 9723:80ac9cf77c9b v7.4.2137
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Aug 1 15:40:54 2016 +0200
patch 7.4.2137
Problem: Using function() with a name will find another function when it is
redefined.
Solution: Add funcref(). Refer to lambda using a partial. Fix several
reference counting issues.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 01 Aug 2016 15:45:07 +0200 |
parents | b74515b8f3d4 |
children | 9560a2eb7968 |
line wrap: on
line diff
--- a/src/channel.c +++ b/src/channel.c @@ -1124,15 +1124,18 @@ set_callback( if (callback != NULL && *callback != NUL) { if (partial != NULL) - *cbp = partial->pt_name; + *cbp = partial_name(partial); else + { *cbp = vim_strsave(callback); + func_ref(*cbp); + } } else *cbp = NULL; *pp = partial; - if (*pp != NULL) - ++(*pp)->pt_refcount; + if (partial != NULL) + ++partial->pt_refcount; } /* @@ -1279,7 +1282,10 @@ channel_set_req_callback( item->cq_callback = callback; } else + { item->cq_callback = vim_strsave(callback); + func_ref(item->cq_callback); + } item->cq_seq_nr = id; item->cq_prev = head->cq_prev; head->cq_prev = item; @@ -3923,14 +3929,24 @@ free_job_options(jobopt_T *opt) { if (opt->jo_partial != NULL) partial_unref(opt->jo_partial); + else if (opt->jo_callback != NULL) + func_unref(opt->jo_callback); if (opt->jo_out_partial != NULL) partial_unref(opt->jo_out_partial); + else if (opt->jo_out_cb != NULL) + func_unref(opt->jo_out_cb); if (opt->jo_err_partial != NULL) partial_unref(opt->jo_err_partial); + else if (opt->jo_err_cb != NULL) + func_unref(opt->jo_err_cb); if (opt->jo_close_partial != NULL) partial_unref(opt->jo_close_partial); + else if (opt->jo_close_cb != NULL) + func_unref(opt->jo_close_cb); if (opt->jo_exit_partial != NULL) partial_unref(opt->jo_exit_partial); + else if (opt->jo_exit_cb != NULL) + func_unref(opt->jo_exit_cb); } /* @@ -4476,7 +4492,10 @@ job_set_options(job_T *job, jobopt_T *op ++job->jv_exit_partial->pt_refcount; } else + { job->jv_exit_cb = vim_strsave(opt->jo_exit_cb); + func_ref(job->jv_exit_cb); + } } } }