diff options
author | Jon Trowbridge <trow@ximian.com> | 2003-03-04 16:23:25 +0000 |
---|---|---|
committer | Jon Trowbridge <trow@src.gnome.org> | 2003-03-04 16:23:25 +0000 |
commit | 511c8a768b3de36bdab05448ffdefd6ef2d43172 (patch) | |
tree | a306f79b13b2f2d2fe0c926e857521d4b141a97d /gobject | |
parent | 8d3122ca22f3d715978809f1f1e63f7b3592c318 (diff) | |
download | pygtk-511c8a768b3de36bdab05448ffdefd6ef2d43172.tar.gz |
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.
Diffstat (limited to 'gobject')
-rw-r--r-- | gobject/gobjectmodule.c | 16 | ||||
-rw-r--r-- | gobject/pygboxed.c | 21 | ||||
-rw-r--r-- | gobject/pygobject.c | 4 |
3 files changed, 34 insertions, 7 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index bd3b727c..f9eb6275 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 6007c615..208a8a27 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 207702e5..29c803d0 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 !"); |