summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2005-10-28 09:12:11 +0000
committerJohan Dahlin <johan@src.gnome.org>2005-10-28 09:12:11 +0000
commit8a05c1e4f6ff6679bb02f5261a73767674e8f91e (patch)
treee5b94e25bbf367bd7052c48e77b0c8772331e4b1
parent7966bae5394bf9260aecd4c1b5797dd13b455589 (diff)
downloadpygobject-pygtk-2-6.tar.gz
Backport reference count and threadsafe fixes from the 2.8 branch.pygtk-2-6
* gobject/pygobject.c: (pygobject_new_with_interfaces): Backport reference count and threadsafe fixes from the 2.8 branch.
-rw-r--r--gobject/pygobject.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gobject/pygobject.c b/gobject/pygobject.c
index 7379a927..3a5fbc28 100644
--- a/gobject/pygobject.c
+++ b/gobject/pygobject.c
@@ -192,6 +192,8 @@ pygobject_new_with_interfaces(GType gtype)
PyObject *modules, *module;
gchar *type_name, *mod_name, *gtype_name;
+ state = pyg_gil_state_ensure();
+
interfaces = g_type_interfaces (gtype, &n_interfaces);
bases = PyTuple_New(n_interfaces+1);
@@ -200,6 +202,7 @@ pygobject_new_with_interfaces(GType gtype)
py_parent_type = pygobject_lookup_class(parent_type);
/* We will always put the parent at the first position in bases */
+ Py_INCREF(py_parent_type); /* PyTuple_SetItem steals a reference */
PyTuple_SetItem(bases, 0, (PyObject*)py_parent_type);
/* And traverse interfaces */
@@ -207,6 +210,7 @@ pygobject_new_with_interfaces(GType gtype)
for (i = 0; i < n_interfaces; i++) {
interface_type = interfaces[i];
py_interface_type = pygobject_lookup_class(interface_type);
+ Py_INCREF(py_interface_type); /* PyTuple_SetItem steals a reference */
PyTuple_SetItem(bases, i+1, (PyObject*)py_interface_type);
}
@@ -245,8 +249,6 @@ pygobject_new_with_interfaces(GType gtype)
type_name = g_strconcat(mod_name, ".", gtype_name, NULL);
}
- state = pyg_gil_state_ensure();
-
type = (PyTypeObject*)PyObject_CallFunction((PyObject*)&PyType_Type, "sOO",
type_name, bases, dict);
g_free(type_name);