From 05af72fc2e2c53eb422d6749b0b7f985eeee0056 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 29 Feb 2024 18:29:32 +0100 Subject: [PATCH] Fix #117795: Refactor code from 9 years ago forgot to cleanup flags of embedded IDs. In 3fcf535d2e, the `ID.flag` data was split, keeping persisten flags in `ID.flag`, and moving runtime ones into a new `ID.tag` data. Some versionning code was then added to cleanup the existing `ID.flag` on file read, but embedded IDs (root node trees only, back then) are not stored in Main data-base, and were skipped. Note that this fixes the conversion of older (2.76.4 and older) files. There is no reliable way to cleanup files opened and saved from more recent versions of Blender unfortunately. --- source/blender/blenloader/intern/versioning_270.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/blender/blenloader/intern/versioning_270.cc b/source/blender/blenloader/intern/versioning_270.cc index fbc877f3b25..1f274170641 100644 --- a/source/blender/blenloader/intern/versioning_270.cc +++ b/source/blender/blenloader/intern/versioning_270.cc @@ -1062,6 +1062,16 @@ void blo_do_versions_270(FileData *fd, Library * /*lib*/, Main *bmain) while (a--) { LISTBASE_FOREACH (ID *, id, lbarray[a]) { id->flag &= LIB_FAKEUSER; + + /* NOTE: This is added in 4.1 code. + * + * Original commit (3fcf535d2e) forgot to handle embedded IDs. Fortunately, back then, the + * only embedded IDs that existed were the NodeTree ones, and the current API to access + * them should still be valid on code from 9 years ago. */ + bNodeTree *node_tree = ntreeFromID(id); + if (node_tree) { + node_tree->id.flag &= LIB_FAKEUSER; + } } } }