[Bf-blender-cvs] [cfae9fb9e48] blender-v2.82-release: Fix T73224: Crash calling UV Sculpt from operator search

Campbell Barton noreply at git.blender.org
Mon Jan 20 10:48:45 CET 2020


Commit: cfae9fb9e4836b61369c4261f5f6a8311f7d18b9
Author: Campbell Barton
Date:   Mon Jan 20 20:45:54 2020 +1100
Branches: blender-v2.82-release
https://developer.blender.org/rBcfae9fb9e4836b61369c4261f5f6a8311f7d18b9

Fix T73224: Crash calling UV Sculpt from operator search

===================================================================

M	source/blender/editors/sculpt_paint/sculpt_uv.c

===================================================================

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;



More information about the Bf-blender-cvs mailing list