| 627 | } |
| 628 | |
| 629 | QString 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 | { |
nothing calls this directly
no test coverage detected