From c01f740e26a5c0ac2aa13200cacd50890f125c06 Mon Sep 17 00:00:00 2001 From: Bryan Forbes Date: Tue, 9 Mar 2010 10:29:11 -0600 Subject: Updated the SWIG bindings for the userdata parameter to np_set_notify_callback. --- swig/imobiledevice.i | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/swig/imobiledevice.i b/swig/imobiledevice.i index 3c9fd3c..2de69e7 100644 --- a/swig/imobiledevice.i +++ b/swig/imobiledevice.i @@ -122,20 +122,15 @@ static PList::Node* new_node_from_plist(plist_t node) } #ifdef SWIGPYTHON -PyObject* python_callback = NULL; - -static void NotificationProxyPythonCallback(const char *notification) { - PyObject *arglist; - PyGILState_STATE gstate; +static void NotificationProxyPythonCallback(const char *notification, void* user_data) { + PyObject *func, *arglist; + func = (PyObject *) user_data; arglist = Py_BuildValue("(s)",notification); - gstate = PyGILState_Ensure(); - - PyEval_CallObject(python_callback, arglist); + PyEval_CallObject(func, arglist); - Py_XDECREF(arglist); - PyGILState_Release(gstate); + Py_DECREF(arglist); } #endif %} @@ -338,8 +333,7 @@ typedef struct { %extend NotificationProxy { int16_t set_callback(PyObject *pyfunc) { int16_t res; - python_callback = pyfunc; - res = np_set_notify_callback($self->client, NotificationProxyPythonCallback); + res = np_set_notify_callback($self->client, NotificationProxyPythonCallback, (void *) pyfunc); Py_INCREF(pyfunc); return res; } -- cgit v1.1-32-gdbae