[Bf-blender-cvs] [150e0553daf] master: Fix T86853: Critical bug in write code of CacheFile ID.

Bastien Montagne noreply at git.blender.org
Thu Mar 25 11:24:56 CET 2021


Commit: 150e0553daff3c9bd6f1921fb1f91a41e4017d78
Author: Bastien Montagne
Date:   Thu Mar 25 11:21:15 2021 +0100
Branches: master
https://developer.blender.org/rB150e0553daff3c9bd6f1921fb1f91a41e4017d78

Fix T86853: Critical bug in write code of CacheFile ID.

CacheFile writing code would not write generic ID data (call for it has
been missing since the initial commit, rB61050f75b13e).

While potentially affecting other areas (mostly CustomProperties/IDProperties),
this was a critical failure for liboverrides. Also added some workaround
code to allow opening broken files (though the override of the CacheFile
data-block will be lost).

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

M	source/blender/blenkernel/intern/cachefile.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/makesrna/intern/rna_access_compare_override.c

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

diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index d233022fd3f..feae033337d 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -99,6 +99,7 @@ static void cache_file_blend_write(BlendWriter *writer, ID *id, const void *id_a
     cache_file->handle_readers = NULL;
 
     BLO_write_id_struct(writer, CacheFile, id_address, &cache_file->id);
+    BKE_id_blend_write(writer, &cache_file->id);
 
     if (cache_file->adt) {
       BKE_animdata_blend_write(writer, cache_file->adt);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index f97f6f65551..b657cb8b2f9 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2497,9 +2497,12 @@ static void direct_link_id_common(
   /* Link direct data of overrides. */
   if (id->override_library) {
     BLO_read_data_address(reader, &id->override_library);
-    BLO_read_list_cb(
-        reader, &id->override_library->properties, direct_link_id_override_property_cb);
-    id->override_library->runtime = NULL;
+    /* Work around file corruption on writing, see T86853. */
+    if (id->override_library != NULL) {
+      BLO_read_list_cb(
+          reader, &id->override_library->properties, direct_link_id_override_property_cb);
+      id->override_library->runtime = NULL;
+    }
   }
 
   DrawDataList *drawdata = DRW_drawdatalist_from_id(id);
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index 80833d4f992..39e7774e5a4 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -1098,6 +1098,10 @@ static void rna_property_override_check_resync(Main *bmain,
   ID *id_dst = rna_property_override_property_real_id_owner(bmain, ptr_item_dst, NULL, NULL);
 
   BLI_assert(id_src == NULL || ID_IS_OVERRIDE_LIBRARY_REAL(id_src));
+  /* Work around file corruption on writing, see T86853. */
+  if (id_src != NULL && !ID_IS_OVERRIDE_LIBRARY_REAL(id_src)) {
+    return;
+  }
 
   if (/* We might be in a case where id_dst has already been processed and its usages
        * remapped to its new local override. In that case overrides and linked data



More information about the Bf-blender-cvs mailing list