little utility function to convert a PyObject * that we know is a string to a QString
| 88 | |
| 89 | // little utility function to convert a PyObject * that we know is a string to a QString |
| 90 | static inline QString ToQStr(PyObject *value) |
| 91 | { |
| 92 | if(value) |
| 93 | { |
| 94 | PyObject *repr = PyObject_Str(value); |
| 95 | if(repr == NULL) |
| 96 | return QString(); |
| 97 | |
| 98 | PyObject *decoded = PyUnicode_AsUTF8String(repr); |
| 99 | if(decoded == NULL) |
| 100 | return QString(); |
| 101 | |
| 102 | QString ret = QString::fromUtf8(PyBytes_AsString(decoded)); |
| 103 | |
| 104 | Py_DecRef(decoded); |
| 105 | Py_DecRef(repr); |
| 106 | |
| 107 | return ret; |
| 108 | } |
| 109 | |
| 110 | return QString(); |
| 111 | } |
| 112 | |
| 113 | static wchar_t program_name[] = L"qrenderdoc"; |
| 114 | static wchar_t python_home[1024] = {0}; |
no test coverage detected