summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2003-03-04 16:23:25 +0000
committerJon Trowbridge <trow@src.gnome.org>2003-03-04 16:23:25 +0000
commit8febf0d579f67b16d347c8c91c69bd7afe3f4034 (patch)
tree09d770dc3fbb65f79b7655a0c986285e65eab351
parentff0a57537a0472e970277b18ee8c2b02844c12c0 (diff)
downloadpygobject-8febf0d579f67b16d347c8c91c69bd7afe3f4034.tar.gz
pygobject-8febf0d579f67b16d347c8c91c69bd7afe3f4034.tar.xz
pygobject-8febf0d579f67b16d347c8c91c69bd7afe3f4034.zip
Unblock threads before invalidating our closures, since this might trigger
2003-03-04 Jon Trowbridge <trow@ximian.com> * pygobject.c (pygobject_dealloc): Unblock threads before invalidating our closures, since this might trigger a destructor that needs to execute python code. (pygobject_clear): Ditto. * pygboxed.c (pyg_boxed_dealloc): Unblock threads before freeing the boxed type, since the destructor may need to execute python code. (pyg_boxed_new): Block threads while we make our Py* calls. (pyg_pointer_new): Block threads while we make our Py* calls. * gobjectmodule.c (pyg_object_set_property): We need to block threads before our call to pygobject_new. (pyg_object_get_property): Ditto.
-rw-r--r--gobject/gobjectmodule.c16
-rw-r--r--gobject/pygboxed.c21
-rw-r--r--gobject/pygobject.c4
3 files changed, 34 insertions, 7 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index bd3b727..f9eb627 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -622,10 +622,14 @@ pyg_object_set_property (GObject *object, guint property_id,
PyObject *object_wrapper, *retval;
PyObject *py_pspec, *py_value;
+ pyg_block_threads();
+
object_wrapper = pygobject_new(object);
- g_return_if_fail(object_wrapper != NULL);
- pyg_block_threads();
+ if (object_wrapper == NULL) {
+ pyg_unblock_threads();
+ g_return_if_fail(object_wrapper != NULL);
+ }
py_pspec = pyg_param_spec_new(pspec);
py_value = pyg_value_as_pyobject (value, TRUE);
@@ -653,10 +657,14 @@ pyg_object_get_property (GObject *object, guint property_id,
PyObject *object_wrapper, *retval;
PyObject *py_pspec;
+ pyg_block_threads();
+
object_wrapper = pygobject_new(object);
- g_return_if_fail(object_wrapper != NULL);
- pyg_block_threads();
+ if (object_wrapper == NULL) {
+ pyg_unblock_threads();
+ g_return_if_fail(object_wrapper != NULL);
+ }
py_pspec = pyg_param_spec_new(pspec);
retval = PyObject_CallMethod(object_wrapper, "do_get_property",
diff --git a/gobject/pygboxed.c b/gobject/pygboxed.c
index 6007c61..208a8a2 100644
--- a/gobject/pygboxed.c
+++ b/gobject/pygboxed.c
@@ -8,8 +8,11 @@
static void
pyg_boxed_dealloc(PyGBoxed *self)
{
- if (self->free_on_dealloc && self->boxed)
+ if (self->free_on_dealloc && self->boxed) {
+ pyg_unblock_threads();
g_boxed_free(self->gtype, self->boxed);
+ pyg_block_threads();
+ }
self->ob_type->tp_free((PyObject *)self);
}
@@ -166,8 +169,11 @@ pyg_boxed_new(GType boxed_type, gpointer boxed, gboolean copy_boxed,
g_return_val_if_fail(boxed_type != 0, NULL);
g_return_val_if_fail(!copy_boxed || (copy_boxed && own_ref), NULL);
+ pyg_block_threads();
+
if (!boxed) {
Py_INCREF(Py_None);
+ pyg_unblock_threads();
return Py_None;
}
@@ -176,8 +182,10 @@ pyg_boxed_new(GType boxed_type, gpointer boxed, gboolean copy_boxed,
tp = (PyTypeObject *)&PyGBoxed_Type; /* fallback */
self = PyObject_NEW(PyGBoxed, tp);
- if (self == NULL)
- return NULL;
+ if (self == NULL) {
+ pyg_unblock_threads();
+ return NULL;
+ }
if (copy_boxed)
boxed = g_boxed_copy(boxed_type, boxed);
@@ -185,6 +193,8 @@ pyg_boxed_new(GType boxed_type, gpointer boxed, gboolean copy_boxed,
self->gtype = boxed_type;
self->free_on_dealloc = own_ref;
+ pyg_unblock_threads();
+
return (PyObject *)self;
}
@@ -330,8 +340,11 @@ pyg_pointer_new(GType pointer_type, gpointer pointer)
g_return_val_if_fail(pointer_type != 0, NULL);
+ pyg_block_threads();
+
if (!pointer) {
Py_INCREF(Py_None);
+ pyg_unblock_threads();
return Py_None;
}
@@ -340,6 +353,8 @@ pyg_pointer_new(GType pointer_type, gpointer pointer)
tp = (PyTypeObject *)&PyGPointer_Type; /* fallback */
self = PyObject_NEW(PyGPointer, tp);
+ pyg_unblock_threads();
+
if (self == NULL)
return NULL;
diff --git a/gobject/pygobject.c b/gobject/pygobject.c
index 207702e..29c803d 100644
--- a/gobject/pygobject.c
+++ b/gobject/pygobject.c
@@ -249,6 +249,7 @@ pygobject_dealloc(PyGObject *self)
}
self->inst_dict = NULL;
+ pyg_unblock_threads();
tmp = self->closures;
while (tmp) {
GClosure *closure = tmp->data;
@@ -259,6 +260,7 @@ pygobject_dealloc(PyGObject *self)
g_closure_invalidate(closure);
}
self->closures = NULL;
+ pyg_block_threads();
/* the following causes problems with subclassed types */
/*self->ob_type->tp_free((PyObject *)self); */
@@ -321,6 +323,7 @@ pygobject_clear(PyGObject *self)
{
GSList *tmp;
+ pyg_unblock_threads();
tmp = self->closures;
while (tmp) {
GClosure *closure = tmp->data;
@@ -330,6 +333,7 @@ pygobject_clear(PyGObject *self)
tmp = tmp->next;
g_closure_invalidate(closure);
}
+ pyg_block_threads();
if (self->closures != NULL)
g_message("invalidated all closures, but self->closures != NULL !");