diff options
author | James Henstridge <james@daa.com.au> | 2001-10-11 00:20:19 +0000 |
---|---|---|
committer | James Henstridge <jamesh@src.gnome.org> | 2001-10-11 00:20:19 +0000 |
commit | e47753e9ffd0431bddfe2d3a4c491c343a40d51f (patch) | |
tree | f74144bf2b821d8e55ba87259d0df0698a53a40a | |
parent | b5467a452e876c16ba587b5bac29c58cd81e916b (diff) | |
download | pygtk-e47753e9ffd0431bddfe2d3a4c491c343a40d51f.tar.gz |
if we are saving a reference to the wrapper during dealloc (which is
2001-10-11 James Henstridge <james@daa.com.au>
* gobjectmodule.c (pygobject_dealloc): if we are saving a
reference to the wrapper during dealloc (which is probably bad),
check if it is a heap type, and if so, incref its type, so that
subtype_dealloc() doesn't decref the type out from under us. This
problem was tracked down by Matt Wilson
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | gobject/gobjectmodule.c | 6 | ||||
-rw-r--r-- | gobjectmodule.c | 6 |
3 files changed, 19 insertions, 0 deletions
@@ -1,3 +1,10 @@ +2001-10-11 James Henstridge <james@daa.com.au> + + * gobjectmodule.c (pygobject_dealloc): if we are saving a + reference to the wrapper during dealloc (which is probably bad), + check if it is a heap type, and if so, incref its type, so that + subtype_dealloc() doesn't decref the type out from under us. This problem was tracked down by Matt Wilson + 2001-10-09 James Henstridge <james@daa.com.au> * gtk/gtk-extrafuncs.defs (GenericTreeModel): fix up c-name. diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index 1b32e380..300cf37c 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -1102,6 +1102,12 @@ pygobject_dealloc(PyGObject *self) g_object_set_qdata_full(obj, pygobject_ownedref_key, self, pygobject_destroy_notify); g_object_unref(obj); + + /* we ref the type, so subtype_dealloc() doesn't kill off our + * instance's type. */ + if (self->ob_type->tp_flags & Py_TPFLAGS_HEAPTYPE) + Py_INCREF(self->ob_type); + return; } if (obj && !self->hasref) /* don't unref the GObject if it owns us */ diff --git a/gobjectmodule.c b/gobjectmodule.c index 1b32e380..300cf37c 100644 --- a/gobjectmodule.c +++ b/gobjectmodule.c @@ -1102,6 +1102,12 @@ pygobject_dealloc(PyGObject *self) g_object_set_qdata_full(obj, pygobject_ownedref_key, self, pygobject_destroy_notify); g_object_unref(obj); + + /* we ref the type, so subtype_dealloc() doesn't kill off our + * instance's type. */ + if (self->ob_type->tp_flags & Py_TPFLAGS_HEAPTYPE) + Py_INCREF(self->ob_type); + return; } if (obj && !self->hasref) /* don't unref the GObject if it owns us */ |