[Bf-blender-cvs] [c361f911f9c] blender-v2.83-release: Fix error versioning paint-slots pre-2.80

Campbell Barton noreply at git.blender.org
Fri May 15 08:52:22 CEST 2020


Commit: c361f911f9c459364fceea5de5b9d0ea2f91c9e9
Author: Campbell Barton
Date:   Fri May 15 16:46:35 2020 +1000
Branches: blender-v2.83-release
https://developer.blender.org/rBc361f911f9c459364fceea5de5b9d0ea2f91c9e9

Fix error versioning paint-slots pre-2.80

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

M	source/blender/blenkernel/intern/paint_toolslots.c

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

diff --git a/source/blender/blenkernel/intern/paint_toolslots.c b/source/blender/blenkernel/intern/paint_toolslots.c
index ea5cb168b12..5e5b5c84997 100644
--- a/source/blender/blenkernel/intern/paint_toolslots.c
+++ b/source/blender/blenkernel/intern/paint_toolslots.c
@@ -33,6 +33,13 @@
 #include "BKE_main.h"
 #include "BKE_paint.h"
 
+/* -------------------------------------------------------------------- */
+/** \name Tool Slot Initialization / Versioning
+ *
+ * These functions run to update old files (while versioning),
+ * take care only to perform low-level functions here.
+ * \{ */
+
 void BKE_paint_toolslots_len_ensure(Paint *paint, int len)
 {
   /* Tool slots are 'uchar'. */
@@ -62,38 +69,54 @@ static void paint_toolslots_init(Main *bmain, Paint *paint)
   }
 }
 
+/**
+ * Initialize runtime since this is called from versioning code.
+ */
+static void paint_toolslots_init_with_runtime(Main *bmain, ToolSettings *ts, Paint *paint)
+{
+  if (paint == NULL) {
+    return;
+  }
+
+  /* Needed so #Paint_Runtime is updated when versioning. */
+  BKE_paint_runtime_init(ts, paint);
+  paint_toolslots_init(bmain, paint);
+}
+
 void BKE_paint_toolslots_init_from_main(struct Main *bmain)
 {
   for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
     ToolSettings *ts = scene->toolsettings;
-    paint_toolslots_init(bmain, &ts->imapaint.paint);
+    paint_toolslots_init_with_runtime(bmain, ts, &ts->imapaint.paint);
     if (ts->sculpt) {
-      paint_toolslots_init(bmain, &ts->sculpt->paint);
+      paint_toolslots_init_with_runtime(bmain, ts, &ts->sculpt->paint);
     }
     if (ts->vpaint) {
-      paint_toolslots_init(bmain, &ts->vpaint->paint);
+      paint_toolslots_init_with_runtime(bmain, ts, &ts->vpaint->paint);
     }
     if (ts->wpaint) {
-      paint_toolslots_init(bmain, &ts->wpaint->paint);
+      paint_toolslots_init_with_runtime(bmain, ts, &ts->wpaint->paint);
     }
     if (ts->uvsculpt) {
-      paint_toolslots_init(bmain, &ts->uvsculpt->paint);
+      paint_toolslots_init_with_runtime(bmain, ts, &ts->uvsculpt->paint);
     }
     if (ts->gp_paint) {
-      paint_toolslots_init(bmain, &ts->gp_paint->paint);
+      paint_toolslots_init_with_runtime(bmain, ts, &ts->gp_paint->paint);
     }
     if (ts->gp_vertexpaint) {
-      paint_toolslots_init(bmain, &ts->gp_vertexpaint->paint);
+      paint_toolslots_init_with_runtime(bmain, ts, &ts->gp_vertexpaint->paint);
     }
     if (ts->gp_sculptpaint) {
-      paint_toolslots_init(bmain, &ts->gp_sculptpaint->paint);
+      paint_toolslots_init_with_runtime(bmain, ts, &ts->gp_sculptpaint->paint);
     }
     if (ts->gp_weightpaint) {
-      paint_toolslots_init(bmain, &ts->gp_weightpaint->paint);
+      paint_toolslots_init_with_runtime(bmain, ts, &ts->gp_weightpaint->paint);
     }
   }
 }
 
+/** \} */
+
 void BKE_paint_toolslots_brush_update_ex(Paint *paint, Brush *brush)
 {
   const uint tool_offset = paint->runtime.tool_offset;



More information about the Bf-blender-cvs mailing list