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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user