From a77fecf44dc4170c4f897810f0857a4a7a40663c Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 28 Mar 2017 17:10:48 +0100 Subject: [PATCH] Wrap BlockInvoke() calls with a helper function that releases the GIL * This means that if we BlockInvoke a python callback, we don't end up in a deadlock where we're holding the GIL during script execution but also waiting on the renderer running (which is trying to acquire the GIL before calling the callback). --- qrenderdoc/Code/pyrenderdoc/qrenderdoc.i | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qrenderdoc/Code/pyrenderdoc/qrenderdoc.i b/qrenderdoc/Code/pyrenderdoc/qrenderdoc.i index c0c4f5b6d..e43b9b483 100644 --- a/qrenderdoc/Code/pyrenderdoc/qrenderdoc.i +++ b/qrenderdoc/Code/pyrenderdoc/qrenderdoc.i @@ -24,6 +24,9 @@ CONTAINER_TYPEMAPS(QMap &) CONTAINER_TYPEMAPS(QMap *) CONTAINER_TYPEMAPS(QMap) +// need to ignore the original function and add a helper that releases the python GIL while calling +%ignore IRenderManager::BlockInvoke; + // ignore these functions as we don't map QVariantMap to/from python %ignore EnvironmentModification::toJSON; %ignore EnvironmentModification::fromJSON; @@ -53,6 +56,17 @@ CONTAINER_TYPEMAPS(QMap) %include "Code/Interface/PersistantConfig.h" %include "Code/Interface/RemoteHost.h" +// unignore the function from above +%rename("%s") IRenderManager::BlockInvoke; + +%extend IRenderManager { + void BlockInvoke(InvokeMethod m) { + Py_BEGIN_ALLOW_THREADS + $self->BlockInvoke(m); + Py_END_ALLOW_THREADS + } +}; + %init %{ PyDateTime_IMPORT; %}