diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-05-25 17:48:44 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-05-25 17:48:44 +0400 |
commit | 6d156a1bab818a8b41dbabca9fb539bde97ad810 (patch) | |
tree | 1d3b4632335034d23ec2a137f4b8a348bdecb76e /source/blender/python/intern/bpy_ui.c | |
parent | edd783db737c2ea6b97b3bb982bd643f840ccd0e (diff) |
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).
Diffstat (limited to 'source/blender/python/intern/bpy_ui.c')
-rw-r--r-- | source/blender/python/intern/bpy_ui.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/source/blender/python/intern/bpy_ui.c b/source/blender/python/intern/bpy_ui.c index bdf656e5e57..1c15fc34547 100644 --- a/source/blender/python/intern/bpy_ui.c +++ b/source/blender/python/intern/bpy_ui.c @@ -303,17 +303,9 @@ static PyObject *Method_registerKey( PyObject * self, PyObject * args ) Py_RETURN_NONE; } -/* internal use only */ -static bContext *get_py_context__internal(void) -{ - PyObject *globals = PyEval_GetGlobals(); - PyObject *val= PyDict_GetItemString(globals, "__bpy_context__"); /* borrow ref */ - return PyCObject_AsVoidPtr(val); -} - static PyObject *Method_getRegonPtr( PyObject * self ) { - bContext *C= get_py_context__internal(); + bContext *C= BPy_GetContext(); ARegion *ar = CTX_wm_region(C); return PyCObject_FromVoidPtr(ar, NULL); @@ -321,7 +313,7 @@ static PyObject *Method_getRegonPtr( PyObject * self ) static PyObject *Method_getAreaPtr( PyObject * self ) { - bContext *C= get_py_context__internal(); + bContext *C= BPy_GetContext(); ScrArea *area = CTX_wm_area(C); return PyCObject_FromVoidPtr(area, NULL); @@ -329,7 +321,7 @@ static PyObject *Method_getAreaPtr( PyObject * self ) static PyObject *Method_getScreenPtr( PyObject * self ) { - bContext *C= get_py_context__internal(); + bContext *C= BPy_GetContext(); bScreen *screen= CTX_wm_screen(C); return PyCObject_FromVoidPtr(screen, NULL); @@ -337,7 +329,7 @@ static PyObject *Method_getScreenPtr( PyObject * self ) static PyObject *Method_getSpacePtr( PyObject * self ) { - bContext *C= get_py_context__internal(); + bContext *C= BPy_GetContext(); SpaceLink *sl= CTX_wm_space_data(C); return PyCObject_FromVoidPtr(sl, NULL); @@ -345,7 +337,7 @@ static PyObject *Method_getSpacePtr( PyObject * self ) static PyObject *Method_getWindowPtr( PyObject * self ) { - bContext *C= get_py_context__internal(); + bContext *C= BPy_GetContext(); wmWindow *window= CTX_wm_window(C); return PyCObject_FromVoidPtr(window, NULL); |