summaryrefslogtreecommitdiffstats
path: root/gobject
diff options
context:
space:
mode:
authorPaul Pogonyshev <pogonyshev@gmx.net>2008-09-09 21:24:34 +0000
committerPaul Pogonyshev <paulp@src.gnome.org>2008-09-09 21:24:34 +0000
commit0f99bd7ce21dcc6ebaa24dfc5c112da1eb2271ad (patch)
treeed289cf329318325f5631aaf35626c11fd07fb7f /gobject
parentec3ab4f8d2d5d4d4d65996cc0a5309ce5e2772f2 (diff)
downloadpygobject-0f99bd7ce21dcc6ebaa24dfc5c112da1eb2271ad.tar.gz
pygobject-0f99bd7ce21dcc6ebaa24dfc5c112da1eb2271ad.tar.xz
pygobject-0f99bd7ce21dcc6ebaa24dfc5c112da1eb2271ad.zip
Bug 530935 – pygobject_set_properties doesnt release the GIL
2008-09-10 Paul Pogonyshev <pogonyshev@gmx.net> 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
Diffstat (limited to 'gobject')
-rw-r--r--gobject/pygobject.c33
1 files changed, 13 insertions, 20 deletions
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 *