Skip to content

Commit 3a5b53b

Browse files
Fix edge case in version upgrade
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.
1 parent 5988645 commit 3a5b53b

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

source/MaterialXCore/Version.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,21 +1240,13 @@ void Document::upgradeVersion()
12401240
for (size_t i = 0; i < destChannelCount; i++)
12411241
{
12421242
InputPtr combineInInput = node->addInput(std::string("in") + std::to_string(i + 1), "float");
1243-
if (i < channelString.size())
1243+
if (i < channelString.size() && CHANNEL_CONSTANT_MAP.count(channelString[i]))
12441244
{
1245-
if (CHANNEL_CONSTANT_MAP.count(channelString[i]))
1246-
{
1247-
combineInInput->setValue(CHANNEL_CONSTANT_MAP.at(channelString[i]));
1248-
}
1249-
else
1250-
{
1251-
copyInputWithBindings(node, inInput->getName(), node, combineInInput->getName());
1252-
}
1245+
combineInInput->setValue(CHANNEL_CONSTANT_MAP.at(channelString[i]));
12531246
}
12541247
else
12551248
{
1256-
combineInInput->setConnectedNode(node);
1257-
combineInInput->setOutputString(combineInInput->isColorType() ? "outr" : "outx");
1249+
copyInputWithBindings(node, inInput->getName(), node, combineInInput->getName());
12581250
}
12591251
}
12601252
node->removeInput(inInput->getName());

0 commit comments

Comments
 (0)