From c361f911f9c459364fceea5de5b9d0ea2f91c9e9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 May 2020 16:46:35 +1000 Subject: Fix error versioning paint-slots pre-2.80 --- source/blender/blenkernel/intern/paint_toolslots.c | 41 +++++++++++++++++----- 1 file changed, 32 insertions(+), 9 deletions(-) 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; -- cgit v1.2.3