[Bf-blender-cvs] [c3d2ad58147] undo-experiments-swap-reread-datablocks: Fix bad handling of unique ID memaddress from merge of undo-experiments.

Bastien Montagne noreply at git.blender.org
Tue Feb 25 17:39:24 CET 2020


Commit: c3d2ad581477a282823344d42468f8d6c21f3492
Author: Bastien Montagne
Date:   Tue Feb 25 17:38:43 2020 +0100
Branches: undo-experiments-swap-reread-datablocks
https://developer.blender.org/rBc3d2ad581477a282823344d42468f8d6c21f3492

Fix bad handling of unique ID memaddress from merge of undo-experiments.

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

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

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 8a1c7187643..1e15d58c266 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9174,13 +9174,6 @@ static BHead *read_libblock(FileData *fd,
     /* do after read_struct, for dna reconstruct */
     lb = which_libbase(main, idcode);
     if (lb) {
-      /* At this point, we know we are going to keep that newly read & allocated ID, so we need to
-       * reallocate it to ensure we actually get a unique memory address for it. */
-      if (!BKE_main_idmemhash_register_id(main, NULL, id)) {
-        id = BKE_main_idmemhash_unique_realloc(
-            main, NULL, id, MEM_reallocN_id, MEM_allocN_len(id), __func__);
-      }
-
       /* for ID_LINK_PLACEHOLDER check */
       oldnewmap_insert(fd->libmap, id_bhead->old, id, id_bhead->code);
 
@@ -9202,6 +9195,15 @@ static BHead *read_libblock(FileData *fd,
         }
       }
 
+      /* At this point, we know we are going to keep that newly read & allocated ID, so we need to
+       * reallocate it to ensure we actually get a unique memory address for it. */
+      if (!do_id_swap) {
+        if (!BKE_main_idmemhash_register_id(main, NULL, id)) {
+          id = BKE_main_idmemhash_unique_realloc(
+              main, NULL, id, MEM_reallocN_id, MEM_allocN_len(id), __func__);
+        }
+      }
+
       /* for ID_LINK_PLACEHOLDER check */
       oldnewmap_insert(fd->libmap, id_bhead->old, do_id_swap ? id_old : id, id_bhead->code);



More information about the Bf-blender-cvs mailing list