mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Nodes: Add versioning for interface socket indentifier sanitization
Discovered during development of !156706. Prior to1561c1ea4asocket identifiers could (in rare cases) essentially be arbitrary names. This is because in version `(2, 66, 2)` the socket names got copied to the identifiers. But since1561c1ea4a, socket identifiers are expected to be valid RNA identifiers. This PR adds versioning code that sanitizes the socket identifiers. Pull Request: https://projects.blender.org/blender/blender/pulls/157286
This commit is contained in:
parent
206a9d7ac6
commit
0d8debaa74
6 changed files with 102 additions and 28 deletions
|
|
@ -326,12 +326,12 @@ class NodeGroupVersioning25Test(AbstractNodeGroupInterfaceTest):
|
|||
self.compare_group_to_specs(group, node, [
|
||||
SocketSpec("Image", "Image", "RGBA", default_value=(0, 0, 0, 1)),
|
||||
SocketSpec("Alpha", "Alpha", "VALUE", default_value=1.0, min_value=0.0, max_value=0.0),
|
||||
SocketSpec("Alpha", "Alpha.001", "VALUE", default_value=0.0, min_value=0.0, max_value=0.0),
|
||||
SocketSpec("Alpha", "Alpha.002", "VALUE", default_value=0.0, min_value=0.0, max_value=0.0),
|
||||
SocketSpec("Alpha", "Alpha_001", "VALUE", default_value=0.0, min_value=0.0, max_value=0.0),
|
||||
SocketSpec("Alpha", "Alpha_002", "VALUE", default_value=0.0, min_value=0.0, max_value=0.0),
|
||||
|
||||
SocketSpec("Fac", "Fac", "VALUE", default_value=0.5, min_value=0.0, max_value=0.0),
|
||||
SocketSpec("ID value", "ID value", "VALUE", default_value=0.8, min_value=0.0, max_value=0.0),
|
||||
SocketSpec("ID value", "ID value.001", "VALUE", default_value=0.8, min_value=0.0, max_value=0.0),
|
||||
SocketSpec("ID value", "ID_value", "VALUE", default_value=0.8, min_value=0.0, max_value=0.0),
|
||||
SocketSpec("ID value", "ID_value_001", "VALUE", default_value=0.8, min_value=0.0, max_value=0.0),
|
||||
], test_links=False)
|
||||
# autopep8: on
|
||||
|
||||
|
|
@ -347,18 +347,42 @@ class NodeGroupVersioning25Test(AbstractNodeGroupInterfaceTest):
|
|||
# autopep8: off
|
||||
self.compare_group_to_specs(group, node, [
|
||||
SocketSpec("Color", "Color", "RGBA", default_value=(0, 0, 0, 1)),
|
||||
SocketSpec("Color", "Color.001", "RGBA", default_value=(0, 0, 0, 1)),
|
||||
SocketSpec("Color", "Color_001", "RGBA", default_value=(0, 0, 0, 1)),
|
||||
SocketSpec("Vector", "Vector", "VECTOR", default_value=(0, 0, 0), min_value=0.0, max_value=0.0),
|
||||
SocketSpec("Value", "Value", "VALUE", default_value=0.0, min_value=0.0, max_value=0.0),
|
||||
|
||||
SocketSpec("Fac", "Fac", "VALUE", default_value=0.5, min_value=0.0, max_value=0.0),
|
||||
SocketSpec("Color1", "Color1", "RGBA", default_value=(0.5, 0.5, 0.5, 1)),
|
||||
SocketSpec("Color2", "Color2", "RGBA", default_value=(0.5, 0.5, 0.5, 1)),
|
||||
SocketSpec("Fac", "Fac.001", "VALUE", default_value=0.5, min_value=0.0, max_value=0.0),
|
||||
SocketSpec("Color1", "Color1.001", "RGBA", default_value=(0.5, 0.5, 0.5, 1)),
|
||||
SocketSpec("Color2", "Color2.001", "RGBA", default_value=(0.5, 0.5, 0.5, 1)),
|
||||
SocketSpec("Fac", "Fac_001", "VALUE", default_value=0.5, min_value=0.0, max_value=0.0),
|
||||
SocketSpec("Color1", "Color1_001", "RGBA", default_value=(0.5, 0.5, 0.5, 1)),
|
||||
SocketSpec("Color2", "Color2_001", "RGBA", default_value=(0.5, 0.5, 0.5, 1)),
|
||||
SocketSpec("Vector", "Vector", "VECTOR", default_value=(0.5, 0.5, 0.5), min_value=0.0, max_value=0.0),
|
||||
SocketSpec("Vector", "Vector.001", "VECTOR", default_value=(0.5, 0.5, 0.5), min_value=0.0, max_value=0.0),
|
||||
SocketSpec("Vector", "Vector_001", "VECTOR", default_value=(0.5, 0.5, 0.5), min_value=0.0, max_value=0.0),
|
||||
], test_links=False)
|
||||
# autopep8: on
|
||||
|
||||
|
||||
class NodeGroupVersioningSocketInterfaceIdentifiersTest(AbstractNodeGroupInterfaceTest):
|
||||
def open_file(self):
|
||||
bpy.ops.wm.open_mainfile(filepath=str(self.testdir / "node_group_socket_interface_compositor.blend"))
|
||||
self.assertEqual(bpy.data.version, (2, 57, 0))
|
||||
|
||||
def test_load_compositor_nodes(self):
|
||||
self.open_file()
|
||||
|
||||
comp_group = bpy.data.node_groups.get('Compositing Nodetree')
|
||||
self.assertIsNotNone(comp_group, "Compositor node group not found")
|
||||
|
||||
group = bpy.data.node_groups['NodeGroup']
|
||||
node = comp_group.nodes['NodeGroup']
|
||||
|
||||
# autopep8: off
|
||||
self.compare_group_to_specs(group, node, [
|
||||
SocketSpec("Image", "Image", "RGBA", default_value=(0, 0, 0, 1)),
|
||||
SocketSpec("Image", "Image", "RGBA", default_value=(0.8, 0.8, 0.8, 1)),
|
||||
SocketSpec("Test Test!@#", "Test_Test___", "VALUE", default_value=0.5, min_value=-2147483648.0, max_value=2147483648.0),
|
||||
SocketSpec("Test Test!@#", "Test_Test____001", "RGBA", default_value=(0.8, 0.8, 0.8, 1)),
|
||||
], test_links=False)
|
||||
# autopep8: on
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue