Fix #130268: Assertion triggered when animate property from Material panel

Fix an assertion that an embedded data-block has a zero 'real user'
count. Apparently it's possible for the shader node tree (embedded by
the material) to have a user count of 1.

Since that looks valid to me (only one user, namely the material itself)
I think it's fine to extend the assertion to that.

I did keep the assertion, to ensure that the embedded data-block is not
shared by multiple users. That shouldn't be possible, in any case.

Pull Request: https://projects.blender.org/blender/blender/pulls/130281
This commit is contained in:
Sybren A. Stüvel
2024-11-15 11:19:44 +01:00
parent 6e508c84a1
commit b3af7e8cd6

View File

@@ -74,7 +74,11 @@ Vector<ID *> find_related_ids(Main &bmain, ID &id)
if (related_id->flag & ID_FLAG_EMBEDDED_DATA) {
/* No matter the type of embedded ID, their owner can always be added to the related IDs. */
BLI_assert(ID_REAL_USERS(related_id) == 0);
/* User counting is irrelevant for the logic here, because embedded IDs cannot be shared.
* Embedded IDs do exist (sometimes) with a non-zero user count, hence the assertion that the
* user count is not greater than 1. */
BLI_assert(ID_REAL_USERS(related_id) <= 1);
ID *owner_id = BKE_id_owner_get(related_id);
/* Embedded IDs should always have an owner. */
BLI_assert(owner_id != nullptr);