MCPcopy Create free account
hub / github.com/baldurk/renderdoc / executeString

Method executeString

qrenderdoc/Code/pyrenderdoc/PythonContext.cpp:926–994  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

924}
925
926void PythonContext::executeString(const QString &filename, const QString &source)
927{
928 if(!initialised())
929 {
930 emit exception(lit("SystemError"), tr("Python integration failed to initialise."), -1, {});
931 return;
932 }
933
934 location.file = filename;
935 location.line = 1;
936
937 PyGILState_STATE gil = PyGILState_Ensure();
938
939 PyObject *compiled =
940 Py_CompileString(source.toUtf8().data(), filename.toUtf8().data(),
941 source.count(QLatin1Char('\n')) == 0 ? Py_single_input : Py_file_input);
942
943 PyObject *ret = NULL;
944
945 if(compiled)
946 {
947 PyObject *traceContext = PyDict_New();
948
949 uintptr_t thisint = (uintptr_t)this;
950 uint64_t thisuint64 = (uint64_t)thisint;
951 PyObject *thisobj = PyLong_FromUnsignedLongLong(thisuint64);
952
953 PyDict_SetItemString(traceContext, "thisobj", thisobj);
954 PyDict_SetItemString(traceContext, "compiled", compiled);
955
956 PyEval_SetTrace(&PythonContext::traceEvent, traceContext);
957
958 m_Abort = false;
959
960 m_State = PyGILState_GetThisThreadState();
961
962 ret = PyEval_EvalCode(compiled, context_namespace, context_namespace);
963
964 m_State = NULL;
965
966 // catch any output
967 outputTick();
968
969 PyEval_SetTrace(NULL, NULL);
970
971 ProcessDecRefQueue();
972
973 Py_XDECREF(thisobj);
974 Py_XDECREF(traceContext);
975 }
976
977 Py_DecRef(compiled);
978
979 QString typeStr;
980 QString valueStr;
981 int finalLine = -1;
982 QList<QString> frames;
983 bool caughtException = (ret == NULL);

Callers 4

RunScriptMethod · 0.80
on_execute_clickedMethod · 0.80
refreshCurrentHelpMethod · 0.80

Calls 7

QLatin1CharClass · 0.85
FetchExceptionFunction · 0.85
toUtf8Method · 0.80
ProcessDecRefQueueFunction · 0.70
trFunction · 0.50
dataMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected