[Bf-blender-cvs] [06c56086460] master: Readfile: Proper fix for `recalc` flags clearing in non-real IDs

Bastien Montagne noreply at git.blender.org
Wed Feb 5 15:51:57 CET 2020


Commit: 06c560864607562acdc1e61b13369f24b22c102c
Author: Bastien Montagne
Date:   Wed Feb 5 15:49:57 2020 +0100
Branches: master
https://developer.blender.org/rB06c560864607562acdc1e61b13369f24b22c102c

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

===================================================================

M	source/blender/blenloader/intern/readfile.c

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 5a834f31528..6db32ef120f 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -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). */



More information about the Bf-blender-cvs mailing list