diff options
| -rw-r--r-- | swig/imobiledevice.i | 18 |
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) | |||
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | #ifdef SWIGPYTHON | 124 | #ifdef SWIGPYTHON |
| 125 | PyObject* python_callback = NULL; | 125 | static void NotificationProxyPythonCallback(const char *notification, void* user_data) { |
| 126 | 126 | PyObject *func, *arglist; | |
| 127 | static void NotificationProxyPythonCallback(const char *notification) { | ||
| 128 | PyObject *arglist; | ||
| 129 | PyGILState_STATE gstate; | ||
| 130 | 127 | ||
| 128 | func = (PyObject *) user_data; | ||
| 131 | arglist = Py_BuildValue("(s)",notification); | 129 | arglist = Py_BuildValue("(s)",notification); |
| 132 | 130 | ||
| 133 | gstate = PyGILState_Ensure(); | 131 | PyEval_CallObject(func, arglist); |
| 134 | |||
| 135 | PyEval_CallObject(python_callback, arglist); | ||
| 136 | 132 | ||
| 137 | Py_XDECREF(arglist); | 133 | Py_DECREF(arglist); |
| 138 | PyGILState_Release(gstate); | ||
| 139 | } | 134 | } |
| 140 | #endif | 135 | #endif |
| 141 | %} | 136 | %} |
| @@ -338,8 +333,7 @@ typedef struct { | |||
| 338 | %extend NotificationProxy { | 333 | %extend NotificationProxy { |
| 339 | int16_t set_callback(PyObject *pyfunc) { | 334 | int16_t set_callback(PyObject *pyfunc) { |
| 340 | int16_t res; | 335 | int16_t res; |
| 341 | python_callback = pyfunc; | 336 | res = np_set_notify_callback($self->client, NotificationProxyPythonCallback, (void *) pyfunc); |
| 342 | res = np_set_notify_callback($self->client, NotificationProxyPythonCallback); | ||
| 343 | Py_INCREF(pyfunc); | 337 | Py_INCREF(pyfunc); |
| 344 | return res; | 338 | return res; |
| 345 | } | 339 | } |
