[Bf-blender-cvs] [e56f284843e] master: readfile: Fix 'virtual' issue in memfile case.
Bastien Montagne
noreply at git.blender.org
Tue Jan 24 18:15:11 CET 2023
Commit: e56f284843e59810d53c0b7ebad826bf5296989a
Author: Bastien Montagne
Date: Tue Jan 24 17:53:27 2023 +0100
Branches: master
https://developer.blender.org/rBe56f284843e59810d53c0b7ebad826bf5296989a
readfile: Fix 'virtual' issue in memfile case.
In many cases when reading undo memfile, n the 'restore id from old
main' part of the process, the 'id_old' is not set, which means that
the call to `BKE_main_idmap_insert_id` would try to dereference a `nullptr`.
In practice this is likely not an issue (see comment in code for details),
but at least explicitely check for a nullptr `id_old` pointer.
Would deffer actual cleanup of this area for after 3.5 is branched out.
===================================================================
M source/blender/blenloader/intern/readfile.cc
===================================================================
diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc
index 1b6c896458a..2ffe8386166 100644
--- a/source/blender/blenloader/intern/readfile.cc
+++ b/source/blender/blenloader/intern/readfile.cc
@@ -3289,11 +3289,23 @@ static BHead *read_libblock(FileData *fd,
* address and inherit recalc flags for the dependency graph. */
ID *id_old = nullptr;
if (fd->flags & FD_FLAGS_IS_MEMFILE) {
+ /* FIXME `read_libblock_undo_restore` currently often skips setting `id_old` even if there
+ * would be a valid matching old ID (libraries, linked data, and `IDTYPE_FLAGS_NO_MEMFILE_UNDO`
+ * id types, at least).
+ *
+ * It is unclear whether this is currently an issue:
+ * * `r_id` is currently only requested by linking code (both independent one, and as part of
+ * loading .blend file through `read_library_linked_ids`).
+ * * `main->id_map` seems to always be `nullptr` in undo case at this point.
+ *
+ * So undo case does not seem to be affected by this. A future cleanup should try to remove
+ * most of this related code in the future, and instead assert that both `r_id` and
+ * `main->id_map` are `nullptr`. */
if (read_libblock_undo_restore(fd, main, bhead, tag, &id_old)) {
if (r_id) {
*r_id = id_old;
}
- if (main->id_map != nullptr) {
+ if (main->id_map != nullptr && id_old != nullptr) {
BKE_main_idmap_insert_id(main->id_map, id_old);
}
More information about the Bf-blender-cvs
mailing list