[Bf-blender-cvs] [0700c045bc7] master: Fix: re-do versioning code for FCurve extremes and Collection colors

Sybren A. Stüvel noreply at git.blender.org
Thu Sep 17 12:02:31 CEST 2020


Commit: 0700c045bc7fb2ec996e04a60eed24f338559924
Author: Sybren A. Stüvel
Date:   Thu Sep 17 12:02:05 2020 +0200
Branches: master
https://developer.blender.org/rB0700c045bc7fb2ec996e04a60eed24f338559924

Fix: re-do versioning code for FCurve extremes and Collection colors

Bump Blender subversion from 4 to 5, and re-execute some versioning code.

Because of a mistake in the versioning code (corrected in rB1a4fc6dcd67b),
some of the versioning code didn't run in certain cases. This subversion
bump ensures that this code is still run.

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

M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenloader/intern/versioning_290.c

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

diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 40a4a2ca0ee..23efea81e57 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 4
+#define BLENDER_FILE_SUBVERSION 5
 
 /* 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 63c3140c084..a975a592b5c 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -640,7 +640,26 @@ 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);
+    }
+  }
 
+  if (!MAIN_VERSION_ATLEAST(bmain, 291, 5)) {
     /* Fix fcurves to allow for new bezier handles behaviour (T75881 and D8752). */
     for (bAction *act = bmain->actions.first; act; act = act->id.next) {
       for (FCurve *fcu = act->curves.first; fcu; fcu = fcu->next) {
@@ -651,9 +670,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
         do_versions_291_fcurve_handles_limit(fcu);
       }
     }
-  }
 
-  if (!MAIN_VERSION_ATLEAST(bmain, 291, 3)) {
     LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
       collection->color_tag = COLLECTION_COLOR_NONE;
     }
@@ -664,22 +681,17 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
         scene->master_collection->color_tag = COLLECTION_COLOR_NONE;
       }
     }
-  }
 
-  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);
+    /* Add custom profile and bevel mode to curve bevels. */
+    if (!DNA_struct_elem_find(fd->filesdna, "Curve", "char", "bevel_mode")) {
+      LISTBASE_FOREACH (Curve *, curve, &bmain->curves) {
+        if (curve->bevobj != NULL) {
+          curve->bevel_mode = CU_BEV_MODE_OBJECT;
+        }
+        else {
+          curve->bevel_mode = CU_BEV_MODE_ROUND;
+        }
+      }
     }
   }
 
@@ -694,17 +706,5 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
    */
   {
     /* Keep this block, even when empty. */
-
-    /* Add custom profile and bevel mode to curve bevels. */
-    if (!DNA_struct_elem_find(fd->filesdna, "Curve", "char", "bevel_mode")) {
-      LISTBASE_FOREACH (Curve *, curve, &bmain->curves) {
-        if (curve->bevobj != NULL) {
-          curve->bevel_mode = CU_BEV_MODE_OBJECT;
-        }
-        else {
-          curve->bevel_mode = CU_BEV_MODE_ROUND;
-        }
-      }
-    }
   }
 }



More information about the Bf-blender-cvs mailing list