[Bf-blender-cvs] [788952705c6] master: IDManagement: Add some assert to ensure lib consistency in embedded IDs.
Bastien Montagne
noreply at git.blender.org
Wed Sep 7 11:26:15 CEST 2022
Commit: 788952705c623d3748c6e46fa244b63bd9209717
Author: Bastien Montagne
Date: Wed Sep 7 11:24:13 2022 +0200
Branches: master
https://developer.blender.org/rB788952705c623d3748c6e46fa244b63bd9209717
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.
===================================================================
M source/blender/blenkernel/intern/collection.c
M source/blender/blenkernel/intern/node.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index cbab1a2de6a..2a544871716 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -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.
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index a685eefcf4f..ab26ccc5d3f 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -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.
More information about the Bf-blender-cvs
mailing list