0

possible (hopeful) fix for the garbage collection bug

This commit is contained in:
Aaron Griffith
2011-07-18 23:56:51 -04:00
parent a7753486dc
commit 931d71103c
2 changed files with 57 additions and 58 deletions

View File

@@ -17,6 +17,10 @@
#include "overviewer.h"
/* global variables from rendermodes.c -- both are dictionaries */
extern PyObject *render_mode_options;
extern PyObject *custom_render_modes;
PyObject *get_extension_version(PyObject *self, PyObject *args) {
return Py_BuildValue("i", OVERVIEWER_EXTENSION_VERSION);
@@ -55,9 +59,22 @@ static PyMethodDef COverviewerMethods[] = {
PyMODINIT_FUNC
initc_overviewer(void)
{
(void)Py_InitModule("c_overviewer", COverviewerMethods);
PyObject *mod = Py_InitModule("c_overviewer", COverviewerMethods);
/* for numpy */
import_array();
/* create the render mode data structures, and attatch them to the module
* so that the Python garbage collector doesn't freak out
*/
render_mode_options = PyDict_New();
PyObject_SetAttrString(mod, "_render_mode_options", render_mode_options);
Py_DECREF(render_mode_options);
custom_render_modes = PyDict_New();
PyObject_SetAttrString(mod, "_custom_render_modes", custom_render_modes);
Py_DECREF(custom_render_modes);
init_endian();
}