From fabbdab847e3e3cc8f48f586218c5a546a819ceb Mon Sep 17 00:00:00 2001 From: Pratik Borhade Date: Tue, 16 Jan 2024 15:45:39 +0530 Subject: [PATCH] Curves: Debug crash after switching to sculpt mode `bounds_min_max` returns an optional and it can be `nullopt` when curve points are 0. --- source/blender/editors/sculpt_paint/paint_image.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc index b73b58dd75f..3b2cb4f5c9c 100644 --- a/source/blender/editors/sculpt_paint/paint_image.cc +++ b/source/blender/editors/sculpt_paint/paint_image.cc @@ -818,8 +818,11 @@ static blender::float3 paint_init_pivot_mesh(Object *ob) static blender::float3 paint_init_pivot_curves(Object *ob) { const Curves &curves = *static_cast(ob->data); - const blender::Bounds bounds = *curves.geometry.wrap().bounds_min_max(); - return blender::math::midpoint(bounds.min, bounds.max); + const std::optional> bounds = curves.geometry.wrap().bounds_min_max(); + if (bounds.has_value()) { + return blender::math::midpoint(bounds->min, bounds->max); + } + return blender::float3(0); } static blender::float3 paint_init_pivot_grease_pencil(Object *ob, const int frame) -- 2.30.2