Skip to content
Snippets Groups Projects
Commit 317e7a27 authored by Cyril Moineau's avatar Cyril Moineau Committed by Cyril Moineau
Browse files

Fix bug when renaming a node with no name.

parent b3d5b86e
No related branches found
No related tags found
2 merge requests!212Version 0.3.0,!150Fix renaming node with no name
...@@ -400,10 +400,15 @@ public: ...@@ -400,10 +400,15 @@ public:
addChild(toOtherNode, mNodeRegistry.at(fromOutNodeName), fromTensor, toTensor); addChild(toOtherNode, mNodeRegistry.at(fromOutNodeName), fromTensor, toTensor);
} }
inline void updateNodeName(const std::string& oldName, const std::string& newName){ inline void updateNodeName(NodePtr nodeToRename, const std::string& newName){
AIDGE_ASSERT(mNodeRegistry.find(oldName) != mNodeRegistry.end(), "No node named {} in graph {}, the graph may be corrupted !", oldName, name()); const std::string& oldName = nodeToRename->name();
mNodeRegistry[newName] = mNodeRegistry[oldName]; if (nodeToRename->name() != ""){ // Case node already had a name
mNodeRegistry.erase(oldName); AIDGE_ASSERT(mNodeRegistry.find(oldName) != mNodeRegistry.end(), "No node named {} in graph {}, the graph may be corrupted !", oldName, name());
mNodeRegistry[newName] = mNodeRegistry[oldName];
mNodeRegistry.erase(oldName);
}else{ // Case node did not had a name
mNodeRegistry[newName] = nodeToRename;
}
} }
/** /**
......
...@@ -64,7 +64,7 @@ Aidge::Connector Aidge::Node::operator()(const std::vector<Connector>& ctors) { ...@@ -64,7 +64,7 @@ Aidge::Connector Aidge::Node::operator()(const std::vector<Connector>& ctors) {
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
void Aidge::Node::setName(const std::string& name) { void Aidge::Node::setName(const std::string& name) {
for (auto graphView : views()) graphView->updateNodeName(mName, name); for (auto graphView : views()) graphView->updateNodeName(shared_from_this(), name);
mName = name; mName = name;
} }
......
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