From d359f620e3f9823390d5297ab0f083a875f556e8 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Fri, 21 Oct 2022 16:15:13 +0200 Subject: [PATCH] Make BBParam properties unique @clone() --- bt/bt_task.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/bt/bt_task.cpp b/bt/bt_task.cpp index 81d551a..1a786d4 100644 --- a/bt/bt_task.cpp +++ b/bt/bt_task.cpp @@ -100,6 +100,33 @@ Ref BTTask::clone() const { c->parent = inst.ptr(); inst->children.set(i, c); } + + // Make BBParam properties unique. + List props; + inst->get_property_list(&props); + Map duplicates; + for (List::Element *E = props.front(); E; E = E->next()) { + if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + continue; + } + + Variant v = inst->get(E->get().name); + + if (v.is_ref()) { + REF ref = v; + if (ref.is_valid()) { + RES res = ref; + if (res.is_valid() && res->is_class("BBParam")) { + if (!duplicates.has(res)) { + duplicates[res] = res->duplicate(); + } + res = duplicates[res]; + inst->set(E->get().name, res); + } + } + } + } + return inst; }