From bca5d0c6713e0e0b06fb90cf251872f7eeb83f9a Mon Sep 17 00:00:00 2001 From: Alessio Quaglino Date: Wed, 16 Jul 2025 09:22:05 -0700 Subject: [PATCH] Update all references after attaching a plugin with multiple references. PiperOrigin-RevId: 783784916 Change-Id: I11da14f11f9206b466bce424979264659bf9a819 --- src/user/user_model.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/user/user_model.cc b/src/user/user_model.cc index 03132736..657f45e7 100644 --- a/src/user/user_model.cc +++ b/src/user/user_model.cc @@ -394,6 +394,14 @@ void mjCModel::CopyPlugin(const std::vector& source, delete candidate; } } + + // update other elements in the list in case of multiple references + for (auto& element : list) { + if (!element->plugin_instance_name.empty()) { + element->spec.plugin.element = + instances.at(element->plugin_instance_name)->spec.plugin.element; + } + } }