mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Step up python stack until we find our globals, or run out of stack
* In python globals aren't really global, they're just module-level variables. So to find our _renderdoc_internal we have to potentailly walk the stack if we're inside another module until we get to the globals dict we set up.
This commit is contained in:
@@ -635,13 +635,23 @@ PyObject *PythonContext::outstream_write(PyObject *self, PyObject *args)
|
||||
// contexts. So look up the global variable that stores the context
|
||||
if(context == NULL)
|
||||
{
|
||||
PyObject *globals = PyEval_GetGlobals();
|
||||
if(globals)
|
||||
_frame *frame = PyEval_GetFrame();
|
||||
|
||||
while(frame)
|
||||
{
|
||||
OutputRedirector *global =
|
||||
(OutputRedirector *)PyDict_GetItemString(globals, "_renderdoc_internal");
|
||||
if(global)
|
||||
context = global->context;
|
||||
PyObject *globals = frame->f_globals;
|
||||
if(globals)
|
||||
{
|
||||
OutputRedirector *global =
|
||||
(OutputRedirector *)PyDict_GetItemString(globals, "_renderdoc_internal");
|
||||
if(global)
|
||||
context = global->context;
|
||||
}
|
||||
|
||||
if(context)
|
||||
break;
|
||||
|
||||
frame = frame->f_back;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user