[Bf-blender-cvs] [5aaf48c052c] undo-experiments-swap-reread-datablocks: Merge branch 'undo-experiments' into undo-experiments-swap-reread-datablocks
Bastien Montagne
noreply at git.blender.org
Wed Jan 29 11:06:03 CET 2020
Commit: 5aaf48c052c9414bb3eaaeb6ce8e81ef989432b0
Author: Bastien Montagne
Date: Wed Jan 29 11:05:52 2020 +0100
Branches: undo-experiments-swap-reread-datablocks
https://developer.blender.org/rB5aaf48c052c9414bb3eaaeb6ce8e81ef989432b0
Merge branch 'undo-experiments' into undo-experiments-swap-reread-datablocks
===================================================================
===================================================================
diff --cc source/blender/blenloader/intern/readfile.c
index a6d5d55b2ed,cd65ceb889d..308c63bb0c2
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@@ -9712,31 -9703,15 +9715,38 @@@ static BHead *read_libblock(FileData *f
oldnewmap_clear(fd->datamap);
if (wrong_id) {
+ /* XXX This is probably working OK currently given the very limited scope of that flag.
+ * However, it is absolutely **not** handled correctly: it is freeing an ID pointer that has
+ * been added to the fd->libmap mapping, which in theory could lead to nice crashes...
+ * This should be properly solved at some point. */
BKE_id_free(main, id);
+ if (r_id != NULL) {
+ *r_id = NULL;
+ }
}
+ else if (do_id_swap) {
+ /* During memfile undo, if an ID changed and we cannot directly re-use existing one from old
+ * bmain, we do a full read of the new id from the memfile, and then fully swap its content
+ * with the old id. This allows us to keep the same pointer even for modified data, which helps
+ * reducing further detected changes by the depsgraph (since unchanged IDs remain fully
+ * unchanged, even if they are using/pointing to a changed one). */
+
+ BLI_assert((fd->skip_flags & BLO_READ_SKIP_UNDO_OLD_MAIN) == 0);
+
+ Main *old_bmain = fd->old_mainlist->first;
+ BLI_assert(old_bmain == BKE_main_idmap_main_get(fd->old_idmap));
+ BLI_assert(id_old != NULL);
+
+ ListBase *old_lb = which_libbase(old_bmain, idcode);
+ ListBase *new_lb = which_libbase(main, idcode);
+ BLI_remlink(old_lb, id_old);
+ BLI_remlink(new_lb, id);
+
+ BKE_id_full_swap(NULL, id, id_old);
+
+ BLI_addtail(new_lb, id_old);
+ BLI_addtail(old_lb, id);
+ }
return (bhead);
}
More information about the Bf-blender-cvs
mailing list