[Bf-blender-cvs] [0c766646c62] undo-experiments: undoexp: Add new 'UNDO_OLD_ID_REUSED' ID tag.

Bastien Montagne noreply at git.blender.org
Thu Jan 2 17:04:55 CET 2020


Commit: 0c766646c626de6bb98b70ef5573d3a74ff4e42f
Author: Bastien Montagne
Date:   Thu Jan 2 17:00:41 2020 +0100
Branches: undo-experiments
https://developer.blender.org/rB0c766646c626de6bb98b70ef5573d3a74ff4e42f

undoexp: Add new 'UNDO_OLD_ID_REUSED' ID tag.

We need to be able to distinguish between reused IDs and newly read
ones, and 'NEW' tag is not enough here, as it gets cleared in read code.

This will be used in next commit to inform depsgraph that some re-used
old IDs need at least a COW refresh, as they are using ID pointers to
newly read data.

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

M	source/blender/blenloader/intern/readfile.c
M	source/blender/makesdna/DNA_ID.h

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index e4b2fce86fc..5444c4ed04e 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9461,7 +9461,7 @@ static BHead *read_libblock(FileData *fd,
           /* Do not add LIB_TAG_NEW here, this should not be needed/used in undo case anyway (as
            * this is only for do_version-like code), but for sake of consistency, and also because
            * it will tell us which ID is re-used from old Main, and which one is actually new. */
-          id->tag = tag | LIB_TAG_NEED_LINK;
+          id->tag = tag | LIB_TAG_NEED_LINK | LIB_TAG_UNDO_OLD_ID_REUSED;
           id->lib = main->curlib;
           id->us = ID_FAKE_USERS(id);
           /* Do not reset id->icon_id here, memory allocated for it remains valid. */
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index fce68b11fe4..fd0a115ccc8 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -558,6 +558,10 @@ enum {
   /* Datablock was not allocated by standard system (BKE_libblock_alloc), do not free its memory
    * (usual type-specific freeing is called though). */
   LIB_TAG_NOT_ALLOCATED = 1 << 18,
+
+  /* RESET_AFTER_USE Used by undo system to tag unchanged IDs re-used from old Main (instead of
+   * read from memfile). */
+  LIB_TAG_UNDO_OLD_ID_REUSED = 1 << 19,
 };
 
 /* Tag given ID for an update in all the dependency graphs. */



More information about the Bf-blender-cvs mailing list