Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-09-16 13:26:16 +0300
committerJacques Lucke <jacques@blender.org>2020-09-16 13:26:16 +0300
commitf14995aba70a46e2629faab6a2d74aef53205d90 (patch)
treef0f55ebb9c41bba0132c08684c8b51c8ef3925ff /source/blender
parent27a5da4dc3a399e1fe7e88dc8722a891e9cfcf78 (diff)
Fix: add versioning to fix incorrectly written customdata
Reviewers: campbellbarton Differential Revision: https://developer.blender.org/D8903
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenloader/intern/versioning_290.c20
2 files changed, 21 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 19350e3e3b0..40a4a2ca0ee 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 3
+#define BLENDER_FILE_SUBVERSION 4
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index aaf4ecbf255..7f2b1714245 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -33,6 +33,7 @@
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_hair_types.h"
+#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_pointcloud_types.h"
@@ -47,6 +48,8 @@
#include "BKE_main.h"
#include "BKE_node.h"
+#include "MEM_guardedalloc.h"
+
#include "BLO_readfile.h"
#include "readfile.h"
@@ -659,6 +662,23 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 291, 4) && MAIN_VERSION_ATLEAST(bmain, 291, 1)) {
+ /* Due to a48d78ce07f4f, CustomData.totlayer and CustomData.maxlayer has been written
+ * incorrectly. Fortunately, the size of the layers array has been written to the .blend file
+ * as well, so we can reconstruct totlayer and maxlayer from that. */
+ LISTBASE_FOREACH (Mesh *, mesh, &bmain->meshes) {
+ mesh->vdata.totlayer = mesh->vdata.maxlayer = MEM_allocN_len(mesh->vdata.layers) /
+ sizeof(CustomDataLayer);
+ mesh->edata.totlayer = mesh->edata.maxlayer = MEM_allocN_len(mesh->edata.layers) /
+ sizeof(CustomDataLayer);
+ /* We can be sure that mesh->fdata is empty for files written by 2.90. */
+ mesh->ldata.totlayer = mesh->ldata.maxlayer = MEM_allocN_len(mesh->ldata.layers) /
+ sizeof(CustomDataLayer);
+ mesh->pdata.totlayer = mesh->pdata.maxlayer = MEM_allocN_len(mesh->pdata.layers) /
+ sizeof(CustomDataLayer);
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*