possible (hopeful) fix for the garbage collection bug
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user