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

Method LoadExtension

qrenderdoc/Code/pyrenderdoc/PythonContext.cpp:629–856  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

627}
628
629QString PythonContext::LoadExtension(ICaptureContext &ctx, const rdcstr &extension)
630{
631 QString ret;
632
633 PyObject *sysobj = PyDict_GetItemString(main_dict, "sys");
634
635 PyObject *syspath = PyObject_SafeGetAttrString(sysobj, "path");
636
637 if(!syspath)
638 qCritical() << "couldn't get sys.path";
639
640 // add extensions directories in
641 for(QString p : PythonContext::GetApplicationExtensionsPaths())
642 {
643 QDir dir(p);
644
645 rdcstr path = dir.absolutePath();
646
647 if(dir.exists())
648 {
649 PyObject *str = PyUnicode_FromString(path.c_str());
650 PyList_Append(syspath, str);
651 Py_DecRef(str);
652 }
653 }
654
655 PyObject *ext = NULL;
656
657 current_global_handle = PyObject_SafeGetAttrString(sysobj, "_renderdoc_internal");
658
659 if(!current_global_handle)
660 qCritical() << "couldn't get _renderdoc_internal";
661
662 QString typeStr;
663 QString valueStr;
664 int finalLine = -1;
665 QList<QString> frames;
666
667 if(extensions[extension] == NULL)
668 {
669 qInfo() << "First load of " << QString(extension);
670 ext = PyImport_ImportModule(extension.c_str());
671 }
672 else
673 {
674 qInfo() << "Reloading " << QString(extension);
675
676 // call unregister() if it exists
677 PyObject *unregister_func = PyObject_SafeGetAttrString(extensions[extension], "unregister");
678
679 bool reloadSuccess = true;
680
681 if(unregister_func)
682 {
683 PyObject *retval = PyObject_CallFunction(unregister_func, "");
684
685 if(retval == NULL)
686 {

Callers

nothing calls this directly

Calls 15

FetchExceptionFunction · 0.85
rdcstrClass · 0.85
QLatin1CharClass · 0.85
existsMethod · 0.80
trimmedMethod · 0.80
toUtf8Method · 0.80
ToQStrFunction · 0.70
QStringFunction · 0.50
trFunction · 0.50
c_strMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected