diff --git a/qrenderdoc/Code/pyrenderdoc/PythonContext.h b/qrenderdoc/Code/pyrenderdoc/PythonContext.h index ddb33631a..7b25ac571 100644 --- a/qrenderdoc/Code/pyrenderdoc/PythonContext.h +++ b/qrenderdoc/Code/pyrenderdoc/PythonContext.h @@ -57,6 +57,9 @@ public: static void ProcessExtensionWork(std::function callback); static bool LoadExtension(ICaptureContext &ctx, const rdcstr &extension); + static void ConvertPyArgs(const ExtensionCallbackData &data, + rdcarray> &args); + static void FreePyArgs(rdcarray> &args); bool CheckInterfaces(); diff --git a/qrenderdoc/Code/pyrenderdoc/pyconversion.h b/qrenderdoc/Code/pyrenderdoc/pyconversion.h index 0e5646937..37880f347 100644 --- a/qrenderdoc/Code/pyrenderdoc/pyconversion.h +++ b/qrenderdoc/Code/pyrenderdoc/pyconversion.h @@ -71,6 +71,27 @@ struct TypeConversion } }; +// specialisations for Python object that just increments the refcount. Only useful if we're doing +// something quite special and manually converting outside from some type we don't want to expose to +// python (this is used for QVariant conversion in python callback arguments). +template <> +struct TypeConversion +{ + static int ConvertFromPy(PyObject *in, PyObject *&out) + { + out = in; + Py_XINCREF(out); + + return 0; + } + + static PyObject *ConvertToPy(PyObject *in) + { + Py_XINCREF(in); + return in; + } +}; + // specialisations for pointer types (opaque handles to be moved not copied) template struct TypeConversion