From 32588169d3ff2177a9e78ff89ba3255830533b76 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 27 Jun 2024 18:38:22 +0200 Subject: [PATCH] Fix: Initialization of paint mode fails in certain files It is possible that the file does not have Grease Pencil paint yet, leading to a crash in the BKE_paint_init(). The simple fix is to swap the order of acquiring the paint pointer and the code which ensures that this paint exists. --- source/blender/blenkernel/intern/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 89fc90d280a..6f49c07251f 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -1174,9 +1174,9 @@ bool BKE_paint_ensure(Main * /*bmain*/, ToolSettings *ts, Paint **r_paint) void BKE_paint_init(Main *bmain, Scene *sce, PaintMode mode, const uchar col[3]) { UnifiedPaintSettings *ups = &sce->toolsettings->unified_paint_settings; - Paint *paint = BKE_paint_get_active_from_paintmode(sce, mode); BKE_paint_ensure_from_paintmode(bmain, sce, mode); + Paint *paint = BKE_paint_get_active_from_paintmode(sce, mode); /* If there's no brush, create one */ Brush *brush = BKE_paint_brush(paint);