From e9c592b5dd35922a85d3784a2d755ff0fd5ae292 Mon Sep 17 00:00:00 2001 From: doomchild Date: Mon, 12 Apr 2010 14:46:04 -0500 Subject: [PATCH] added debugging messages to deallocation --- dfhack/python/DF_API.cpp | 23 +++++++++++++++++++---- dfhack/python/DF_CreatureManager.cpp | 12 +++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/dfhack/python/DF_API.cpp b/dfhack/python/DF_API.cpp index 2d864d04d..89085b97e 100644 --- a/dfhack/python/DF_API.cpp +++ b/dfhack/python/DF_API.cpp @@ -86,22 +86,37 @@ static int DF_API_init(DF_API* self, PyObject* args, PyObject* kwds) static void DF_API_dealloc(DF_API* self) { + PySys_WriteStdout("API dealloc\n"); + if(self != NULL) { - Py_CLEAR(self->mem_info); - Py_CLEAR(self->position); - Py_CLEAR(self->material); - Py_CLEAR(self->creature); + PySys_WriteStdout("creature xdecref\n"); + Py_XDECREF(self->creature); + + PySys_WriteStdout("mem_info xdecref\n"); + Py_XDECREF(self->mem_info); + + PySys_WriteStdout("position xdecref\n"); + Py_XDECREF(self->position); + + PySys_WriteStdout("material xdecref\n"); + Py_XDECREF(self->material); if(self->api_Ptr != NULL) { + PySys_WriteStdout("api_Ptr = %i\n", (int)self->api_Ptr); + delete self->api_Ptr; + PySys_WriteStdout("api_Ptr deleted\n"); + self->api_Ptr = NULL; } self->ob_type->tp_free((PyObject*)self); } + + PySys_WriteStdout("API dealloc done\n"); } // Accessors diff --git a/dfhack/python/DF_CreatureManager.cpp b/dfhack/python/DF_CreatureManager.cpp index 9a1d229f2..43e08f230 100644 --- a/dfhack/python/DF_CreatureManager.cpp +++ b/dfhack/python/DF_CreatureManager.cpp @@ -59,17 +59,27 @@ static int DF_CreatureManager_init(DF_CreatureManager* self, PyObject* args, PyO static void DF_CreatureManager_dealloc(DF_CreatureManager* self) { + PySys_WriteStdout("creature manager dealloc\n"); + if(self != NULL) - { + { + PySys_WriteStdout("creature manager not NULL\n"); + if(self->creature_Ptr != NULL) { + PySys_WriteStdout("creature_Ptr = %i\n", (int)self->creature_Ptr); + delete self->creature_Ptr; + PySys_WriteStdout("creature_Ptr deleted\n"); + self->creature_Ptr = NULL; } self->ob_type->tp_free((PyObject*)self); } + + PySys_WriteStdout("creature manager dealloc done\n"); } // Type methods