diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc index d7db103a460..938041368f0 100644 --- a/source/blender/blenloader/intern/readfile.cc +++ b/source/blender/blenloader/intern/readfile.cc @@ -2034,7 +2034,7 @@ static void direct_link_id_common( id->py_instance = nullptr; /* Initialize with provided tag. */ - id->tag = tag; + id->tag = tag | (id->tag & LIB_TAG_KEEP_ON_UNDO); if (ID_IS_LINKED(id)) { id->library_weak_reference = nullptr; @@ -3105,7 +3105,7 @@ static void read_libblock_undo_restore_identical( BLI_assert(id_old != nullptr); /* Some tags need to be preserved here. */ - id_old->tag = tag | (id_old->tag & LIB_TAG_EXTRAUSER); + id_old->tag = tag | (id_old->tag & LIB_TAG_KEEP_ON_UNDO); id_old->lib = main->curlib; id_old->us = ID_FAKE_USERS(id_old); /* Do not reset id->icon_id here, memory allocated for it remains valid. */ diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc index bc1a90fb022..7e2840c3379 100644 --- a/source/blender/blenloader/intern/writefile.cc +++ b/source/blender/blenloader/intern/writefile.cc @@ -1253,7 +1253,7 @@ static bool write_file_handle(Main *mainvar, memcpy(id_buffer, id, idtype_struct_size); /* Clear runtime data to reduce false detection of changed data in undo/redo context. */ - ((ID *)id_buffer)->tag = 0; + ((ID *)id_buffer)->tag &= LIB_TAG_KEEP_ON_UNDO; ((ID *)id_buffer)->us = 0; ((ID *)id_buffer)->icon_id = 0; /* Those listbase data change every time we add/remove an ID, and also often when diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 3feb341b773..fb23dd8644a 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -848,6 +848,15 @@ enum { LIB_TAG_LIB_OVERRIDE_NEED_RESYNC = 1 << 21, }; +/** + * Most of ID tags are cleared on file write (i.e. also when storing undo steps), since they + * either have of very short lifetime (not expected to exist accross undo steps), or are info that + * will be re-generated when reading undo steps. + * + * However a few of these need to be explicitely preserved accross undo steps. + */ +#define LIB_TAG_KEEP_ON_UNDO (LIB_TAG_EXTRAUSER | LIB_TAG_MISSING) + /* Tag given ID for an update in all the dependency graphs. */ typedef enum IDRecalcFlag { /***************************************************************************