From 6711fcf4dcb504a8c12d92c361b24d315fd036d5 Mon Sep 17 00:00:00 2001 From: James Henstridge Date: Thu, 11 Oct 2001 00:20:19 +0000 Subject: if we are saving a reference to the wrapper during dealloc (which is 2001-10-11 James Henstridge * 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 --- gobject/gobjectmodule.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gobject') diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index 1b32e38..300cf37 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 */ -- cgit