From 2e74989b697a732d3afa9440a679262804bfb8bc Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 1 Jan 2018 14:29:52 +0000 Subject: [PATCH] Allow None when converting std::function types * It just creates an empty callback --- qrenderdoc/Code/pyrenderdoc/function_conversion.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qrenderdoc/Code/pyrenderdoc/function_conversion.h b/qrenderdoc/Code/pyrenderdoc/function_conversion.h index 8b2b63044..8df1f3bd7 100644 --- a/qrenderdoc/Code/pyrenderdoc/function_conversion.h +++ b/qrenderdoc/Code/pyrenderdoc/function_conversion.h @@ -155,7 +155,7 @@ struct varfunc rettype call(const char *funcname, PyObject *func, PyObject *global_handle, ExceptionHandling &exHandle) { - if(!func || func == Py_None || !PyCallable_Check(func) || !args) + if(!func || !PyCallable_Check(func) || !args) { HandleCallbackFailure(global_handle, exHandle); return rettype(); @@ -197,6 +197,10 @@ struct ScopedFuncCall template funcType ConvertFunc(const char *funcname, PyObject *func, ExceptionHandling &exHandle) { + // allow None to indicate no callback + if(func == Py_None) + return funcType(); + // add a reference to the global object so it stays alive while we execute, in case this is an // async call PyObject *global_internal_handle = NULL;