Skip to content
Snippets Groups Projects
Commit 5bd831da authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

fix: modify model while visiting

Modifying the model while visiting is not allowed because the
modification invalidates the iterators used for visiting. This lead in
this case to a very subtle crash (segfault) only appearing under very
specific circumstances (only when running in ctest and only on some
Ubuntu 20.04 machines).
parent dba39544
No related branches found
No related tags found
No related merge requests found
......@@ -93,6 +93,8 @@ namespace ChimeraTK {
}
// find the right PV in the model
VariableNetworkNode theNode;
Model::ProcessVariableProxy theProxy;
neighbourDirectory.visitByPath(registerName, [&](auto proxy) {
if constexpr(isVariable(proxy)) {
assert(proxy.isValid());
......@@ -100,12 +102,17 @@ namespace ChimeraTK {
// find the right node (belonging to our device) to remove
for(auto& proxyNode : proxy.getNodes()) {
if(proxyNode.getType() == NodeType::Device && proxyNode.getDeviceAlias() == getDeviceAliasOrURI()) {
proxy.removeNode(proxyNode);
theProxy = proxy;
theNode = proxyNode;
break;
}
}
}
});
if(theNode.isValid()) {
assert(theProxy.isValid());
theProxy.removeNode(theNode);
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment