Store the context for python in a static variable with assessor functions - BPy_GetContext/BPy_SetContext,

Still not happy with this in the long term but its less problematic then storing the context in pythons namespace which couldn't be set before importing modules.

This might fix a crash quite a few people have reported (but I cant reproduce).
This commit is contained in:
2009-05-25 13:48:44 +00:00
parent edd783db73
commit 6d156a1bab
6 changed files with 23 additions and 25 deletions

View File

@@ -1968,10 +1968,7 @@ PyObject *pyrna_basetype_register(PyObject *self, PyObject *args)
}
/* get the context, so register callback can do necessary refreshes */
item= PyDict_GetItemString(PyEval_GetGlobals(), "__bpy_context__"); /* borrow ref */
if(item)
C= (bContext*)PyCObject_AsVoidPtr(item);
C= BPy_GetContext();
/* call the register callback */
BKE_reports_init(&reports, RPT_PRINT);
@@ -2031,10 +2028,8 @@ PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *args)
}
/* get the context, so register callback can do necessary refreshes */
item= PyDict_GetItemString(PyEval_GetGlobals(), "__bpy_context__"); /* borrow ref */
if(item)
C= (bContext*)PyCObject_AsVoidPtr(item);
C= BPy_GetContext();
/* call unregister */
unreg(C, py_srna->ptr.data);