diff options
author | James Booth <boothj5@gmail.com> | 2016-07-04 00:41:29 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-07-04 00:41:29 +0100 |
commit | 71879a3f64f5f04cdceeedf0317175b2bab1701c (patch) | |
tree | d97c05b977718ef679892468e449a72972db99ae /src/plugins/python_api.c | |
parent | 606a860bdc2fd93773405655be467064aa949cc6 (diff) | |
download | profani-tty-71879a3f64f5f04cdceeedf0317175b2bab1701c.tar.gz |
Free plugins commands on quit
Diffstat (limited to 'src/plugins/python_api.c')
-rw-r--r-- | src/plugins/python_api.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c index 1a60a07c..82cf22eb 100644 --- a/src/plugins/python_api.c +++ b/src/plugins/python_api.c @@ -166,19 +166,18 @@ python_api_register_command(PyObject *self, PyObject *args) allow_python_threads(); api_register_command(plugin_name, command_name, min_args, max_args, c_synopsis, - description, c_arguments, c_examples, p_callback, python_command_callback); + description, c_arguments, c_examples, p_callback, python_command_callback, NULL); disable_python_threads(); } + free(plugin_name); + return Py_BuildValue(""); } static PyObject * python_api_register_timed(PyObject *self, PyObject *args) { - char *plugin_name = _python_plugin_name(); - log_debug("Register timed for %s", plugin_name); - PyObject *p_callback = NULL; int interval_seconds = 0; @@ -186,12 +185,17 @@ python_api_register_timed(PyObject *self, PyObject *args) return Py_BuildValue(""); } + char *plugin_name = _python_plugin_name(); + log_debug("Register timed for %s", plugin_name); + if (p_callback && PyCallable_Check(p_callback)) { allow_python_threads(); - api_register_timed(plugin_name, p_callback, interval_seconds, python_timed_callback); + api_register_timed(plugin_name, p_callback, interval_seconds, python_timed_callback, NULL); disable_python_threads(); } + free(plugin_name); + return Py_BuildValue(""); } @@ -223,6 +227,8 @@ python_api_completer_add(PyObject *self, PyObject *args) api_completer_add(plugin_name, key, c_items); disable_python_threads(); + free(plugin_name); + return Py_BuildValue(""); } @@ -456,19 +462,21 @@ python_api_win_create(PyObject *self, PyObject *args) char *tag = NULL; PyObject *p_callback = NULL; - char *plugin_name = _python_plugin_name(); - log_debug("Win create %s for %s", tag, plugin_name); - if (!PyArg_ParseTuple(args, "sO", &tag, &p_callback)) { return Py_BuildValue(""); } + char *plugin_name = _python_plugin_name(); + log_debug("Win create %s for %s", tag, plugin_name); + if (p_callback && PyCallable_Check(p_callback)) { allow_python_threads(); - api_win_create(plugin_name, tag, p_callback, NULL, python_window_callback); + api_win_create(plugin_name, tag, p_callback, python_window_callback, NULL); disable_python_threads(); } + free(plugin_name); + return Py_BuildValue(""); } |