Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2022-09-06 18:22:10 +0300
committerBastien Montagne <bastien@blender.org>2022-09-06 19:01:53 +0300
commite46687c3aacfd69bde83187233e73a8cc6fa5d8d (patch)
treebb858bc021cd804ed96c79bf599106351005e3ee /source/blender/blenkernel/intern/node.cc
parente047b2618a48a7d88ac606d6eb280b52c9c72ebd (diff)
Address to some extent issues with invalid embedded IDs in existing files.
Many existing .blend files (including startup ones) seem to have invalid embedded IDs (they are not properly tagged with `LIB_EMBEDDED_DATA`). We cannot `do_version` this so just fix it on the fly when detecting the issue. User then need to re-save these files. We also need to update some release files (default factory startup is OK, but e.g. the VSE template one is not). Keeping the assert is important here, as such missing flag is a critical data corruption that can potentially have many serious consequences throughout the ID management code.
Diffstat (limited to 'source/blender/blenkernel/intern/node.cc')
-rw-r--r--source/blender/blenkernel/intern/node.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index e648d9577d2..97512c9a84e 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -654,6 +654,20 @@ 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);
+ 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.
+ *
+ * NOTE: Using do_version is not a solution here, since this code will be called before any
+ * do_version takes place. Keeping it here also ensures future (or unknown existing) similar
+ * bugs won't go easily unoticed. */
+ CLOG_WARN(&LOG,
+ "Fixing root node tree '%s' owned by '%s' missing EMBEDDED tag, please consider "
+ "re-saving your (startup) file",
+ ntree->id.name,
+ owner_id->name);
+ ntree->id.flag |= LIB_EMBEDDED_DATA;
+ }
ntree->owner_id = owner_id;
/* NOTE: writing and reading goes in sync, for speed. */