IDManagement: Add some assert to ensure lib consistency in embedded IDs.

From re-checking related code, it seems that we already always ensure
consistency of the `lib` pointer between embedded IDs and their owners.

This commit only adds some asserts in ambedded ID read code to
double-check this.
This commit is contained in:
Bastien Montagne 2022-09-07 11:24:13 +02:00
parent 46642507ae
commit 788952705c
Notes: blender-bot 2023-02-14 10:29:32 +01:00
Referenced by issue #69169, Improve handling of embedded data-blocks (root nodetrees and master collections)
2 changed files with 2 additions and 0 deletions

View File

@ -236,6 +236,7 @@ void BKE_collection_blend_read_data(BlendDataReader *reader, Collection *collect
/* Special case for this pointer, do not rely on regular `lib_link` process here. Avoids needs
* for do_versioning, and ensures coherence of data in any case. */
BLI_assert((collection->id.flag & LIB_EMBEDDED_DATA) != 0 || owner_id == NULL);
BLI_assert(owner_id == NULL || owner_id->lib == collection->id.lib);
if (owner_id != NULL && (collection->id.flag & LIB_EMBEDDED_DATA) == 0) {
/* This is unfortunate, but currently a lot of existing files (including startup ones) have
* missing `LIB_EMBEDDED_DATA` flag.

View File

@ -654,6 +654,7 @@ void ntreeBlendReadData(BlendDataReader *reader, ID *owner_id, bNodeTree *ntree)
/* Special case for this pointer, do not rely on regular `lib_link` process here. Avoids needs
* for do_versioning, and ensures coherence of data in any case. */
BLI_assert((ntree->id.flag & LIB_EMBEDDED_DATA) != 0 || owner_id == nullptr);
BLI_assert(owner_id == NULL || owner_id->lib == ntree->id.lib);
if (owner_id != nullptr && (ntree->id.flag & LIB_EMBEDDED_DATA) == 0) {
/* This is unfortunate, but currently a lot of existing files (including startup ones) have
* missing `LIB_EMBEDDED_DATA` flag.