Readfile: Proper fix for `recalc` flags clearing in non-real IDs

In current `readfile.c` code we have that:

https://developer.blender.org/diffusion/B/browse/master/source/blender/blenloader/intern/readfile.c$3523

This is unconditionally clearing nodetree's recalc flags, and was added by rB81a762e79f83 ages ago. Thing is, in main ID read code we only clear that flag when **not** in undo context.

This proposed change intends to properly handle those cases, by moving `id.recalc` flags clearing from `read_libblock()` to `direct_link_id()`, which is also called for all 'local' IDs (ntrees and master collections currently).

I’d expect that change to be straightforward (and maybe even fixing some odd undocumented bugs), however there is no .blend file testcases associated with changes in rB81a762e79f83, so wouldn’t mind that to be double checked before it goes to master.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D6711
This commit is contained in:
Bastien Montagne 2020-02-05 15:49:57 +01:00 committed by Bastien Montagne
parent ea2e6995a9
commit 06c5608646
1 changed files with 12 additions and 14 deletions

View File

@ -2668,6 +2668,18 @@ static void direct_link_id(FileData *fd, ID *id)
id->tag = 0;
id->flag &= ~LIB_INDIRECT_WEAK_LINK;
/* NOTE: It is important to not clear the recalc flags for undo/redo.
* Preserving recalc flags on redo/undo is the only way to make dependency graph detect
* that animation is to be evaluated on undo/redo. If this is not enforced by the recalc
* flags dependency graph does not do animation update to avoid loss of unkeyed changes.,
* which conflicts with undo/redo of changes to animation data itself.
*
* But for regular file load we clear the flag, since the flags might have been changed since
* the version the file has been saved with. */
if (!fd->memfile) {
id->recalc = 0;
}
/* Link direct data of overrides. */
if (id->override_library) {
id->override_library = newdataadr(fd, id->override_library);
@ -3520,8 +3532,6 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
ntree->adt = newdataadr(fd, ntree->adt);
direct_link_animdata(fd, ntree->adt);
ntree->id.recalc &= ~ID_RECALC_ALL;
link_list(fd, &ntree->nodes);
for (node = ntree->nodes.first; node; node = node->next) {
node->typeinfo = NULL;
@ -9419,18 +9429,6 @@ static BHead *read_libblock(FileData *fd,
id->newid = NULL; /* Needed because .blend may have been saved with crap value here... */
id->orig_id = NULL;
/* NOTE: It is important to not clear the recalc flags for undo/redo.
* Preserving recalc flags on redo/undo is the only way to make dependency graph detect
* that animation is to be evaluated on undo/redo. If this is not enforced by the recalc
* flags dependency graph does not do animation update to avoid loss of unkeyed changes.,
* which conflicts with undo/redo of changes to animation data itself.
*
* But for regular file load we clear the flag, since the flags might have been changed since
* the version the file has been saved with. */
if (!fd->memfile) {
id->recalc = 0;
}
/* this case cannot be direct_linked: it's just the ID part */
if (bhead->code == ID_LINK_PLACEHOLDER) {
/* That way, we know which data-lock needs do_versions (required currently for linking). */