Fix (unreported) crash in 'startup.blend' GP default update code.
This commit fixes two different issues in `BLO_update_defaults_startup_blend`: * No check were done whether a given 'paint mode' tool settings actually exist or not before trying to 'update' it, leading to hard crash when some did not. * Only the first Scene in loaded 'startup' Main would be processed - nothing prevents a `startup.blend` file to have more than one scene!
This commit is contained in:
parent
c1b4af86b9
commit
5f7f6b65f3
|
@ -475,23 +475,37 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
|
|||
}
|
||||
|
||||
/* Reset all grease pencil brushes. */
|
||||
Scene *scene = static_cast<Scene *>(bmain->scenes.first);
|
||||
BKE_brush_gpencil_paint_presets(bmain, scene->toolsettings, true);
|
||||
BKE_brush_gpencil_sculpt_presets(bmain, scene->toolsettings, true);
|
||||
BKE_brush_gpencil_vertex_presets(bmain, scene->toolsettings, true);
|
||||
BKE_brush_gpencil_weight_presets(bmain, scene->toolsettings, true);
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
|
||||
/* Ensure new Paint modes. */
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_VERTEX_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_SCULPT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_WEIGHT_GPENCIL);
|
||||
if (ts->gp_paint) {
|
||||
BKE_brush_gpencil_paint_presets(bmain, ts, true);
|
||||
}
|
||||
if (ts->gp_sculptpaint) {
|
||||
BKE_brush_gpencil_sculpt_presets(bmain, ts, true);
|
||||
}
|
||||
if (ts->gp_vertexpaint) {
|
||||
BKE_brush_gpencil_vertex_presets(bmain, ts, true);
|
||||
}
|
||||
if (ts->gp_weightpaint) {
|
||||
BKE_brush_gpencil_weight_presets(bmain, ts, true);
|
||||
}
|
||||
|
||||
/* Enable cursor. */
|
||||
GpPaint *gp_paint = scene->toolsettings->gp_paint;
|
||||
gp_paint->paint.flags |= PAINT_SHOW_BRUSH;
|
||||
/* Ensure new Paint modes. */
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_VERTEX_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_SCULPT_GPENCIL);
|
||||
BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_WEIGHT_GPENCIL);
|
||||
|
||||
/* Ensure Palette by default. */
|
||||
BKE_gpencil_palette_ensure(bmain, scene);
|
||||
/* Enable cursor. */
|
||||
if (ts->gp_paint) {
|
||||
ts->gp_paint->paint.flags |= PAINT_SHOW_BRUSH;
|
||||
}
|
||||
|
||||
/* Ensure Palette by default. */
|
||||
if (ts->gp_paint) {
|
||||
BKE_gpencil_palette_ensure(bmain, scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* For builtin templates only. */
|
||||
|
|
Loading…
Reference in New Issue