From 0f99bd7ce21dcc6ebaa24dfc5c112da1eb2271ad Mon Sep 17 00:00:00 2001 From: Paul Pogonyshev Date: Tue, 9 Sep 2008 21:24:34 +0000 Subject: Bug 530935 – pygobject_set_properties doesnt release the GIL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2008-09-10 Paul Pogonyshev Bug 530935 – pygobject_set_properties doesnt release the GIL * gobject/pygobject.c (pygobject_set_properties): Reuse set_property_from_pspec() which release GIL for us. Also make sure that g_object_thaw_notify() is called even after error. svn path=/trunk/; revision=970 --- gobject/pygobject.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'gobject') diff --git a/gobject/pygobject.c b/gobject/pygobject.c index 242833e..c2deb9c 100644 --- a/gobject/pygobject.c +++ b/gobject/pygobject.c @@ -1294,6 +1294,7 @@ pygobject_set_properties(PyGObject *self, PyObject *args, PyObject *kwargs) Py_ssize_t pos; PyObject *value; PyObject *key; + PyObject *result = NULL; CHECK_GOBJECT(self); @@ -1303,38 +1304,30 @@ pygobject_set_properties(PyGObject *self, PyObject *args, PyObject *kwargs) pos = 0; while (kwargs && PyDict_Next (kwargs, &pos, &key, &value)) { - gchar *key_str = _PyUnicode_AsString (key); - GParamSpec *pspec; - GValue gvalue ={ 0, }; + gchar *key_str = _PyUnicode_AsString(key); + GParamSpec *pspec; - pspec = g_object_class_find_property (class, key_str); - if (!pspec) { + pspec = g_object_class_find_property(class, key_str); + if (!pspec) { gchar buf[512]; g_snprintf(buf, sizeof(buf), "object `%s' doesn't support property `%s'", g_type_name(G_OBJECT_TYPE(self->obj)), key_str); PyErr_SetString(PyExc_TypeError, buf); - return NULL; + goto exit; } - g_value_init(&gvalue, G_PARAM_SPEC_VALUE_TYPE(pspec)); - if (pyg_value_from_pyobject(&gvalue, value)) { - gchar buf[512]; - - g_snprintf(buf, sizeof(buf), - "could not convert value for property `%s'", key_str); - PyErr_SetString(PyExc_TypeError, buf); - return NULL; - } - g_object_set_property(G_OBJECT(self->obj), key_str, &gvalue); - g_value_unset(&gvalue); + if (!set_property_from_pspec(G_OBJECT(self->obj), key_str, pspec, value)) + goto exit; } - g_object_thaw_notify (G_OBJECT(self->obj)); + result = Py_None; - Py_INCREF(Py_None); - return Py_None; + exit: + g_object_thaw_notify (G_OBJECT(self->obj)); + Py_XINCREF(result); + return result; } static PyObject * -- cgit