nodes: fix serialized ID typos with backward compatibility

- ChromaKey tolerance inputs are now spelled "upper/lower_tolerance_in";
  old projects with the misspelled "tolerence" IDs keep loading (values
  and connections) via a new Node::GetInputIDForLegacyID() hook applied
  in LoadInput and connection deserialization
- flip/ripple/swirl/tile/wave node IDs moved to the consistent
  org.olivevideoeditor.Olive.* domain; NodeFactory::CreateFromID maps
  the old org.oliveeditor.* IDs so old projects still resolve
- Regression tests: legacy ChromaKey IDs (values + connections) and
  legacy factory IDs
This commit is contained in:
2026-07-17 08:38:25 +08:00
parent 2aa921b215
commit bec52b46b3
13 changed files with 139 additions and 18 deletions
+38
View File
@@ -16,6 +16,7 @@
#include "node/generator/solid/solid.h"
#include "node/generator/text/textv3.h"
#include "node/keyframe.h"
#include "node/keying/chromakey/chromakey.h"
#include "node/math/math/math.h"
#include "node/node.h"
#include "node/project.h"
@@ -617,3 +618,40 @@ TEST_F(NodeSaveLoadTest, ConnectionsLinksAndPositionsResolveAfterProjectLoad)
olive::NodeFactory::Destroy();
}
TEST_F(NodeSaveLoadTest, LegacyMisspelledChromaKeyIDsAreMapped)
{
auto *src = AddNode<olive::ChromaKeyNode>();
src->SetStandardValue(olive::ChromaKeyNode::kUpperToleranceInput, 42.0);
src->SetStandardValue(olive::ChromaKeyNode::kLowerToleranceInput, 7.0);
auto *math = AddNode<olive::MathNode>();
olive::Node::ConnectEdge(
math, olive::NodeInput(src, olive::ChromaKeyNode::kUpperToleranceInput));
QString xml = SaveNodeXml(src);
// Simulate an old project file written with the misspelled "tolerence" IDs
xml.replace(QStringLiteral("upper_tolerance_in"),
QStringLiteral("upper_tolerence_in"));
xml.replace(QStringLiteral("lower_tolerance_in"),
QStringLiteral("lower_tolerence_in"));
olive::ChromaKeyNode loaded;
olive::SerializedData data;
ASSERT_TRUE(LoadNodeXml(&loaded, xml, &data));
EXPECT_DOUBLE_EQ(
loaded.GetStandardValue(olive::ChromaKeyNode::kUpperToleranceInput)
.toDouble(),
42.0);
EXPECT_DOUBLE_EQ(
loaded.GetStandardValue(olive::ChromaKeyNode::kLowerToleranceInput)
.toDouble(),
7.0);
// Connections to the renamed inputs are remapped too
ASSERT_EQ(data.desired_connections.size(), 1);
EXPECT_EQ(data.desired_connections.first().input.input(),
olive::ChromaKeyNode::kUpperToleranceInput);
}