[Bf-blender-cvs] [ea3efd130dc] undo-experiments: properly use 'unique ID allocation' when reading new ID in undo case.

Bastien Montagne noreply at git.blender.org
Fri Feb 14 19:04:21 CET 2020


Commit: ea3efd130dc841e1371bb225af5c8079db9ba826
Author: Bastien Montagne
Date:   Fri Feb 14 19:03:48 2020 +0100
Branches: undo-experiments
https://developer.blender.org/rBea3efd130dc841e1371bb225af5c8079db9ba826

properly use 'unique ID allocation' when reading new ID in undo case.

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

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

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index e44f6693a0c..b305ec9ea71 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2324,7 +2324,13 @@ static void *read_struct(FileData *fd, BHead *bh, const char *blockname)
       }
       else {
         /* SDNA_CMP_EQUAL */
-        temp = MEM_mallocN(bh->len, blockname);
+        if (fd->memfile != NULL && !ELEM(bh->code, DATA, GLOB, DNA1, TEST, REND, USER, ENDB)) {
+          Main *bmain = fd->mainlist->first;
+          temp = BKE_main_idmemset_unique_alloc(bmain, MEM_mallocN, (size_t)bh->len, blockname);
+        }
+        else {
+          temp = MEM_mallocN(bh->len, blockname);
+        }
 #ifdef USE_BHEAD_READ_ON_DEMAND
         if (BHEADN_FROM_BHEAD(bh)->has_data) {
           memcpy(temp, (bh + 1), bh->len);
@@ -9214,10 +9220,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;
 
-  const bool is_id_memaddress_unique = BKE_main_idmemset_register_id(main, id);
-  /* Note: this is likely to fail at some point with current undo/redo code! */
-  BLI_assert(is_id_memaddress_unique);
-
   /* this case cannot be direct_linked: it's just the ID part */
   if (id_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