From cfae9fb9e4836b61369c4261f5f6a8311f7d18b9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Jan 2020 20:45:54 +1100 Subject: Fix T73224: Crash calling UV Sculpt from operator search --- source/blender/editors/sculpt_paint/sculpt_uv.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/sculpt_paint') diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 72b02436b92..5beaff5ef00 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -807,6 +807,23 @@ static int uv_sculpt_stroke_modal(bContext *C, wmOperator *op, const wmEvent *ev return OPERATOR_RUNNING_MODAL; } +static bool uv_sculpt_stroke_poll(bContext *C) +{ + if (ED_operator_uvedit_space_image(C)) { + /* While these values could be initialized on demand, + * the only case this would be useful is running from the operator search popup. + * This is such a corner case that it's simpler to check a brush has already been created + * (something the tool system ensures). */ + Scene *scene = CTX_data_scene(C); + ToolSettings *ts = scene->toolsettings; + Brush *brush = BKE_paint_brush(&ts->uvsculpt->paint); + if (brush != NULL) { + return true; + } + } + return false; +} + void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot) { static const EnumPropertyItem stroke_mode_items[] = { @@ -832,7 +849,7 @@ void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot) /* api callbacks */ ot->invoke = uv_sculpt_stroke_invoke; ot->modal = uv_sculpt_stroke_modal; - ot->poll = ED_operator_uvedit_space_image; + ot->poll = uv_sculpt_stroke_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -- cgit v1.2.3