From d37b0ee00b5f153ee6a2a931a416d061d54200ee Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 3 Dec 2024 14:34:11 +0000 Subject: [PATCH] Fix issue with iterating actions via previous/next in python * We keep parent references when returning child objects via reference/python object wrappers rather than copying. But when iterating a linked list like the actions this can produce an incredibly long parent chain and then on destruction we can stack overflow if the chain is long enough. --- qrenderdoc/Code/pyrenderdoc/renderdoc.i | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qrenderdoc/Code/pyrenderdoc/renderdoc.i b/qrenderdoc/Code/pyrenderdoc/renderdoc.i index 6b7f8df73..4ada3f515 100644 --- a/qrenderdoc/Code/pyrenderdoc/renderdoc.i +++ b/qrenderdoc/Code/pyrenderdoc/renderdoc.i @@ -214,6 +214,21 @@ VA_IGNORE_REST_OF_FILE $1.assign(*$input); } +%typemap(ret) const ActionDescription * { + // for ActionDescription pointers don't apply parent tracking, since these are preserved + // in other ways and the linked-list nature of walking them can produce absurdly long + // parent chains + if (SwigPyObject_Check($result)) + { + SwigPyObject *sobj = (SwigPyObject *)$result; + if(sobj->parent) + { + sobj->parent = NULL; + Py_DECREF($self); + } + } +} + SIMPLE_TYPEMAPS(rdcstr) SIMPLE_TYPEMAPS(rdcinflexiblestr) SIMPLE_TYPEMAPS(rdcdatetime)