diff options
author | Johan Dahlin <johan@src.gnome.org> | 2004-08-02 11:03:05 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2004-08-02 11:03:05 +0000 |
commit | 3e41db376f6e40c2df01a1f83c2ecf10a5315084 (patch) | |
tree | a4146d2ca0d7516cbcd334048286a710e2692a58 /gobject/pygtype.c | |
parent | fa82703297dadadf71b26650a8bafd55fc101dce (diff) | |
download | pygobject-3e41db376f6e40c2df01a1f83c2ecf10a5315084.tar.gz |
Call PyEval_InitThreads. Perhaps its something that always should bePYGTK_2_3_95
* gobject/gobjectmodule.c (initgobject): Call
PyEval_InitThreads. Perhaps its something that always should be
called.
* README (Author): Add a requirements section
* configure.in: Require Python 2.3
* setup.py (version): Ditto
* gobject/pygtype.c, gobject/pygobject.h: Remove 2.2 compat.
* All over the place: Add support for PyGILState.
Diffstat (limited to 'gobject/pygtype.c')
-rw-r--r-- | gobject/pygtype.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/gobject/pygtype.c b/gobject/pygtype.c index edf01f0d..e6b97ff2 100644 --- a/gobject/pygtype.c +++ b/gobject/pygtype.c @@ -133,10 +133,8 @@ pyg_type_from_object(PyObject *obj) if (tp == &PyInt_Type) return G_TYPE_INT; -#if PY_VERSION_HEX >= 0x020300f0 else if (tp == &PyBool_Type) return G_TYPE_BOOLEAN; -#endif else if (tp == &PyLong_Type) return G_TYPE_LONG; else if (tp == &PyFloat_Type) @@ -736,7 +734,6 @@ pyg_closure_invalidate(gpointer data, GClosure *closure) pyg_unblock_threads(); } -/* XXXX - need to handle python thread context stuff */ static void pyg_closure_marshal(GClosure *closure, GValue *return_value, @@ -745,11 +742,14 @@ pyg_closure_marshal(GClosure *closure, gpointer invocation_hint, gpointer marshal_data) { + PyGILState_STATE state; PyGClosure *pc = (PyGClosure *)closure; PyObject *params, *ret; guint i; pyg_block_threads(); + state = PyGILState_Ensure(); + /* construct Python tuple for the parameter values */ params = PyTuple_New(n_param_values); for (i = 0; i < n_param_values; i++) { @@ -763,9 +763,7 @@ pyg_closure_marshal(GClosure *closure, /* error condition */ if (!item) { - Py_DECREF(params); - pyg_unblock_threads(); - return; + goto out; } PyTuple_SetItem(params, i, item); } @@ -779,14 +777,16 @@ pyg_closure_marshal(GClosure *closure, ret = PyObject_CallObject(pc->callback, params); if (ret == NULL) { PyErr_Print(); - Py_DECREF(params); - pyg_unblock_threads(); - return; + goto out; } if (return_value) pyg_value_from_pyobject(return_value, ret); - Py_DECREF(params); Py_DECREF(ret); + + out: + Py_DECREF(params); + + PyGILState_Release(state); pyg_unblock_threads(); } |