[Bf-blender-cvs] [b0f96397335] master: Fix crash due to improper handling of new library runtime name_map data on read/write.

Bastien Montagne noreply at git.blender.org
Thu Jul 21 16:39:13 CEST 2022


Commit: b0f9639733500e7c3deedc36c2ef6b9685a756ee
Author: Bastien Montagne
Date:   Thu Jul 21 16:36:06 2022 +0200
Branches: master
https://developer.blender.org/rBb0f9639733500e7c3deedc36c2ef6b9685a756ee

Fix crash due to improper handling of new library runtime name_map data on read/write.

Code handling read/write of libraries is still particular... but trying
to call `library_runtime_reset` on a random address at readtime was an
obvious mistake I should have caught during review :(

Regression from rB7f8d05131a77.

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

M	source/blender/blenkernel/intern/library.c
M	source/blender/blenloader/intern/writefile.c

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

diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index fee4cae2701..dd58c9cc4fe 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -73,18 +73,10 @@ static void library_foreach_path(ID *id, BPathForeachPathData *bpath_data)
   }
 }
 
-static void library_blend_write(struct BlendWriter *UNUSED(writer),
-                                ID *id,
-                                const void *UNUSED(id_address))
-{
-  Library *lib = (Library *)id;
-  library_runtime_reset(lib);
-}
-
 static void library_blend_read_data(struct BlendDataReader *UNUSED(reader), ID *id)
 {
   Library *lib = (Library *)id;
-  library_runtime_reset(lib);
+  lib->runtime.name_map = NULL;
 }
 
 IDTypeInfo IDType_ID_LI = {
@@ -107,7 +99,7 @@ IDTypeInfo IDType_ID_LI = {
     .foreach_path = library_foreach_path,
     .owner_get = NULL,
 
-    .blend_write = library_blend_write,
+    .blend_write = NULL,
     .blend_read_data = library_blend_read_data,
     .blend_read_lib = NULL,
     .blend_read_expand = NULL,
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 68171f26a66..1ec056a9f50 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -970,10 +970,15 @@ static void write_libraries(WriteData *wd, Main *main)
     if (found_one) {
       /* Not overridable. */
 
+      void *runtime_name_data = main->curlib->runtime.name_map;
+      main->curlib->runtime.name_map = NULL;
+
       BlendWriter writer = {wd};
       writestruct(wd, ID_LI, Library, 1, main->curlib);
       BKE_id_blend_write(&writer, &main->curlib->id);
 
+      main->curlib->runtime.name_map = runtime_name_data;
+
       if (main->curlib->packedfile) {
         BKE_packedfile_blend_write(&writer, main->curlib->packedfile);
         if (wd->use_memfile == false) {



More information about the Bf-blender-cvs mailing list