[Bf-blender-cvs] [6e3ec62a6a5] undo-experiments-swap-reread-datablocks: undoexp: Update for new 'ID memaddress unique' feature.

Bastien Montagne noreply at git.blender.org
Tue Feb 11 18:22:14 CET 2020


Commit: 6e3ec62a6a57bb6467b66afbde41f135c8e3f01b
Author: Bastien Montagne
Date:   Tue Feb 11 18:06:01 2020 +0100
Branches: undo-experiments-swap-reread-datablocks
https://developer.blender.org/rB6e3ec62a6a57bb6467b66afbde41f135c8e3f01b

undoexp: Update for new 'ID memaddress unique' feature.

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

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

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index bd734ffde94..9260c5cdd85 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9229,9 +9229,17 @@ 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);
+  if (do_id_swap) {
+    const bool is_id_memaddress_already_registered = !BKE_main_idmemset_register_id(main, id_old);
+    /* Should never fail, since we re-used an existing ID it should have already been
+     * registered. */
+    BLI_assert(is_id_memaddress_already_registered);
+  }
+  else {
+    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) {



More information about the Bf-blender-cvs mailing list