Skip to content

Commit

Permalink
Fix edge case in version upgrade
Browse files Browse the repository at this point in the history
This changelist fixes an edge case in the version upgrade logic from 1.38 to 1.39, where a swizzle node with a single-channel input and an empty channels string would upgrade incorrectly, generating a graph with a cycle.
  • Loading branch information
jstone-lucasfilm committed Jul 17, 2024
1 parent 5988645 commit 3a5b53b
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions source/MaterialXCore/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1240,21 +1240,13 @@ void Document::upgradeVersion()
for (size_t i = 0; i < destChannelCount; i++)
{
InputPtr combineInInput = node->addInput(std::string("in") + std::to_string(i + 1), "float");
if (i < channelString.size())
if (i < channelString.size() && CHANNEL_CONSTANT_MAP.count(channelString[i]))
{
if (CHANNEL_CONSTANT_MAP.count(channelString[i]))
{
combineInInput->setValue(CHANNEL_CONSTANT_MAP.at(channelString[i]));
}
else
{
copyInputWithBindings(node, inInput->getName(), node, combineInInput->getName());
}
combineInInput->setValue(CHANNEL_CONSTANT_MAP.at(channelString[i]));
}
else
{
combineInInput->setConnectedNode(node);
combineInInput->setOutputString(combineInInput->isColorType() ? "outr" : "outx");
copyInputWithBindings(node, inInput->getName(), node, combineInInput->getName());
}
}
node->removeInput(inInput->getName());
Expand Down

0 comments on commit 3a5b53b

Please sign in to comment.