diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-12-17 19:31:15 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-12-17 19:31:15 +0300 |
commit | 4b21067aea415f7eb4604de6dd133a67a4063640 (patch) | |
tree | 5a4aafe466163e3f011569166801099072b9ad99 /source/blender/blenlib/tests/BLI_listbase_test.cc | |
parent | 2648d920d8ac5c590a6fc28ee1cbb5bc48a9bc07 (diff) |
Fix T94116: Drivers can have multiple variables with same name
The RNA setter now ensures that driver variables are uniquely named
(within the scope of the driver).
Versioning code has been added to ensure this uniqueness. The last
variable with the non-unique name retains the original name; this
ensures that the driver will still evaluate to the same value as before
this fix.
This also introduces a new blenlib function `BLI_listbase_from_link()`,
which can be used to find the entire list from any item within the list.
Manifest Task: T94116
Reviewed By: mont29, JacquesLucke
Maniphest Tasks: T94116
Differential Revision: https://developer.blender.org/D13594
Diffstat (limited to 'source/blender/blenlib/tests/BLI_listbase_test.cc')
-rw-r--r-- | source/blender/blenlib/tests/BLI_listbase_test.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/blenlib/tests/BLI_listbase_test.cc b/source/blender/blenlib/tests/BLI_listbase_test.cc index d66eb214902..9e4d7c7dd36 100644 --- a/source/blender/blenlib/tests/BLI_listbase_test.cc +++ b/source/blender/blenlib/tests/BLI_listbase_test.cc @@ -154,6 +154,31 @@ TEST(listbase, FindLinkFromStringOrPointer) BLI_freelistN(&lb); } +TEST(listbase, FromLink) +{ + ListBase lb = {nullptr, nullptr}; + Link *link1 = static_cast<Link *>(MEM_callocN(sizeof(Link), "link1")); + Link *link2 = static_cast<Link *>(MEM_callocN(sizeof(Link), "link2")); + Link *link3 = static_cast<Link *>(MEM_callocN(sizeof(Link), "link3")); + + /* NULL safety. */ + EXPECT_EQ(lb, BLI_listbase_from_link(nullptr)); + + /* One link. */ + BLI_addtail(&lb, link1); + EXPECT_EQ(lb, BLI_listbase_from_link(link1)); + + /* Two links. */ + BLI_addtail(&lb, link2); + EXPECT_EQ(lb, BLI_listbase_from_link(link2)); + + /* Three links, search from middle. */ + BLI_addtail(&lb, link3); + EXPECT_EQ(lb, BLI_listbase_from_link(link2)); + + BLI_freelistN(&lb); +} + /* -------------------------------------------------------------------- */ /* Sort utilities & test */ |