From 56e35a4e8917b0b9b49fa0ba2bc114c44660a4e7 Mon Sep 17 00:00:00 2001 From: Jon Trowbridge Date: Wed, 8 Jan 2003 22:06:07 +0000 Subject: Wrap Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS around the call to 2003-01-08 Jon Trowbridge * pygobject.c (pygobject_dealloc): Wrap Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS around the call to g_object_unref. We need to do this because the object finalizers might trigger other code that has to acquire the interpreter lock, causing a deadlock. Fixes #102756. * gtk/gtk-types.c (pygtk_style_helper_dealloc): Wrap the call to g_object_unref in Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS. This should let us avoid other instances of bug #102756. (pygtk_style_helper_setitem): Ditto. (pygtk_tree_model_row_dealloc): Ditto. (pygtk_tree_model_row_iter_dealloc): Ditto. * gtk/gdk.override (pygdk_unblock_threads, pygdk_unblock_threads): Restored David I Lehn's patch (#98380). His patch was fine --- it just caused bug #102756 to emerge. --- gobject/pygobject.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gobject/pygobject.c b/gobject/pygobject.c index ca41dd8a..3affe469 100644 --- a/gobject/pygobject.c +++ b/gobject/pygobject.c @@ -216,7 +216,10 @@ pygobject_dealloc(PyGObject *self) self->hasref = TRUE; g_object_set_qdata_full(obj, pygobject_ownedref_key, self, pyg_destroy_notify); + + Py_BEGIN_ALLOW_THREADS; g_object_unref(obj); + Py_END_ALLOW_THREADS; /* we ref the type, so subtype_dealloc() doesn't kill off our * instance's type. */ @@ -231,8 +234,11 @@ pygobject_dealloc(PyGObject *self) return; } - if (obj && !self->hasref) /* don't unref the GObject if it owns us */ + if (obj && !self->hasref) { /* don't unref the GObject if it owns us */ + Py_BEGIN_ALLOW_THREADS; g_object_unref(obj); + Py_END_ALLOW_THREADS; + } PyObject_ClearWeakRefs((PyObject *)self); -- cgit v1.2.1