summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--swig/imobiledevice.i18
1 files 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;
}