LibOverride: Prevent matching collection items only by their index if a name and ID are provided.

If an item name (and ID) is provided, never successfully match only
based on the item index.

This can lead to matching to a complete different ID than the intended
one, which can be catastrophic for the integrity of the next resync.

Also, do not require sucessful match on both source and destination
data, this will always fail in case e.g. an item is removed from a
collection, and can prevent detecting required resync from that
collection then.

This commit also enables new 'harder' test in unittests, added in
previous commit, which is now expected to pass.

Pull Request: https://projects.blender.org/blender/blender/pulls/144429
This commit is contained in:
Bastien Montagne
2025-08-11 20:14:14 +02:00
committed by Gitea
parent 00375abc38
commit cbf763e700
2 changed files with 38 additions and 5 deletions

View File

@@ -632,8 +632,8 @@ class TestLibraryOverridesComplex(TestHelper):
# Sub-container 1 is moved from collection_container to sub-container 0.
collection_subcontainer_0 = bpy.data.collections[self.__class__.DATA_NAME_SUBCONTAINER_0]
collection_subcontainer_1 = bpy.data.collections[self.__class__.DATA_NAME_SUBCONTAINER_1]
# ~ collection_container.children.unlink(collection_subcontainer_1)
# ~ collection_subcontainer_0.children.link(collection_subcontainer_1)
collection_container.children.unlink(collection_subcontainer_1)
collection_subcontainer_0.children.link(collection_subcontainer_1)
self.edit_lib_data(edit_lib_cb)
self.reset()