Skip to content

Commit

Permalink
Update related input attribute when renaming a nodegraph (#1930)
Browse files Browse the repository at this point in the history
Fixes #1912

The problem is that after renaming, the input PortElement's `_attributeMap` still hold the old name, so when drawing the graph, `getConnectedOutput` failed.
  • Loading branch information
jsjtxietian committed Jul 13, 2024
1 parent dfffe83 commit a86f677
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions source/MaterialXGraphEditor/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2752,6 +2752,10 @@ void Graph::deleteLinkInfo(int startAttr, int endAttr)
{
int upNode = getNodeId(startAttr);
int downNode = getNodeId(endAttr);
if (upNode == -1 || downNode == -1)
{
return;
}

// Change input to default value
if (_graphNodes[downNode]->getNode())
Expand Down Expand Up @@ -3354,6 +3358,23 @@ void Graph::propertyEditor()
std::string name = _currUiNode->getNodeGraph()->getParent()->createValidChildName(temp);
_currUiNode->getNodeGraph()->setName(name);
_currUiNode->setName(name);

for (UiNodePtr node : _graphNodes)
{
if (!node->getInput())
{
std::vector<UiPinPtr> inputs = node->inputPins;
for (size_t i = 0; i < inputs.size(); i++)
{
const std::string& inputName = inputs[i]->_name;
UiNodePtr inputNode = node->getConnectedNode(inputName);
if (inputNode && inputNode->getName() == name && node->getNode())
{
node->getNode()->getInput(inputName)->setAttribute("nodegraph", name);
}
}
}
}
}
}

Expand Down

0 comments on commit a86f677

Please sign in to comment.