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

@@ -90,9 +90,7 @@ static PyObject *CreateGlobalDictionary( bContext *C )
Py_DECREF(item);
// XXX - evil, need to access context
item = PyCObject_FromVoidPtr( C, NULL );
PyDict_SetItemString( dict, "__bpy_context__", item );
Py_DECREF(item);
BPy_SetContext(C);
// XXX - put somewhere more logical
{
@@ -386,6 +384,8 @@ void BPY_run_ui_scripts(bContext *C, int reload)
PySys_SetObject("path", sys_path_new);
Py_DECREF(sys_path_new);
// XXX - evil, need to access context
BPy_SetContext(C);
while((de = readdir(dir)) != NULL) {
/* We could stat the file but easier just to let python