From 52f907197674a66444f6f4ddbaccc5d8488e786d Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Sat, 28 Dec 2002 14:38:45 +0000 Subject: Improve threading support by adding pyg_thread_block/unblock around all * gobjectmodule.c, gtk/gtk.override, gtk/pygtkcellrenderer.c, gtk/pygtktreemodel: Improve threading support by adding pyg_thread_block/unblock around all PyObject_Call* and g_object_refs. Based upon patch by Jon Trowbridge. Fixes #99102. --- gobject/gobjectmodule.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index da2aa72..4a35cc6 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -384,8 +384,11 @@ pyg_object_set_property (GObject *object, guint property_id, object_wrapper = pygobject_new(object); g_return_if_fail(object_wrapper != NULL); + pyg_block_threads(); + py_pspec = pyg_param_spec_new(pspec); py_value = pyg_value_as_pyobject (value, TRUE); + retval = PyObject_CallMethod(object_wrapper, "do_set_property", "OO", py_pspec, py_value); if (retval) { @@ -394,9 +397,12 @@ pyg_object_set_property (GObject *object, guint property_id, PyErr_Print(); PyErr_Clear(); } + Py_DECREF(object_wrapper); Py_DECREF(py_pspec); Py_DECREF(py_value); + + pyg_unblock_threads(); } static void @@ -409,6 +415,8 @@ pyg_object_get_property (GObject *object, guint property_id, object_wrapper = pygobject_new(object); g_return_if_fail(object_wrapper != NULL); + pyg_block_threads(); + py_pspec = pyg_param_spec_new(pspec); retval = PyObject_CallMethod(object_wrapper, "do_get_property", "O", py_pspec); @@ -419,6 +427,8 @@ pyg_object_get_property (GObject *object, guint property_id, Py_DECREF(object_wrapper); Py_DECREF(py_pspec); Py_XDECREF(retval); + + pyg_unblock_threads(); } static void @@ -1335,6 +1345,7 @@ iowatch_marshal(GIOChannel *source, GIOCondition condition, gpointer user_data) res = PyObject_IsTrue(ret); Py_DECREF(ret); } + pyg_unblock_threads(); return res; @@ -1505,7 +1516,9 @@ pyg_error_check(GError **error) if (*error != NULL) { PyObject *exc_instance; PyObject *d; - + + pyg_unblock_threads(); + exc_instance = PyObject_CallFunction(gerror_exc, "z", (*error)->message); PyObject_SetAttrString(exc_instance, "domain", @@ -1525,6 +1538,9 @@ pyg_error_check(GError **error) PyErr_SetObject(gerror_exc, exc_instance); Py_DECREF(exc_instance); g_clear_error(error); + + pyg_unblock_threads(); + return TRUE; } return FALSE; -- cgit