Fix T102940: "Mask by Color" sculpt tool crash

We need to ensure the mask layer exists before running the operator.
I made the order of function calls here the same as in newer code later
on in this file for consistency.

Differential Revision: https://developer.blender.org/D16696
This commit is contained in:
Hans Goudey 2022-12-06 10:00:12 -06:00 committed by Harley Acheson
parent 16b6116b9d
commit 64541b242a
Notes: blender-bot 2023-02-14 09:19:09 +01:00
Referenced by issue #102940, Regression: Blender 3.4.0 Release Candidate crash on 'Mask by Color'
1 changed files with 4 additions and 2 deletions

View File

@ -910,13 +910,15 @@ static int sculpt_mask_by_color_invoke(bContext *C, wmOperator *op, const wmEven
v3d->shading.color_type = V3D_SHADING_VERTEX_COLOR;
}
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true, false);
/* Color data is not available in multi-resolution or dynamic topology. */
if (!SCULPT_handles_colors_report(ss, op->reports)) {
return OPERATOR_CANCELLED;
}
MultiresModifierData *mmd = BKE_sculpt_multires_active(CTX_data_scene(C), ob);
BKE_sculpt_mask_layers_ensure(depsgraph, CTX_data_main(C), ob, mmd);
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true, false);
SCULPT_vertex_random_access_ensure(ss);
/* Tools that are not brushes do not have the brush gizmo to update the vertex as the mouse move,