diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-05-04 07:34:55 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-05-04 07:34:55 +0400 |
commit | 41dbd19b4d19daada4f0189107b4f3aa9a043869 (patch) | |
tree | 65f651ec11fc5e32444920270e2989cd05b4068c /source/blender | |
parent | c56fe3efe6e5c739e6c24f5f57c1d52dfd3ddc68 (diff) |
fix for crash executing sculpt via python.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 9 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 14 |
2 files changed, 13 insertions, 10 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index b63c2973758..e7b62505417 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -896,11 +896,20 @@ int paint_stroke_exec(bContext *C, wmOperator *op) { PaintStroke *stroke = op->customdata; + /* only when executed for the first time */ + if(stroke->stroke_started == 0) { + /* XXX stroke->last_mouse_position is unset, this may cause problems */ + stroke->test_start(C, op, NULL); + stroke->stroke_started= 1; + } + RNA_BEGIN(op->ptr, itemptr, "stroke") { stroke->update_step(C, stroke, &itemptr); } RNA_END; + stroke->done(C, stroke); + MEM_freeN(stroke); op->customdata = NULL; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index e4385131db1..1ed4764c629 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3462,8 +3462,9 @@ static int over_mesh(bContext *C, struct wmOperator *op, float x, float y) static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent *event) { - /* Don't start the stroke until mouse goes over the mesh */ - if(over_mesh(C, op, event->x, event->y)) { + /* Don't start the stroke until mouse goes over the mesh. + * note: event will only be null when re-executing the saved stroke. */ + if(event==NULL || over_mesh(C, op, event->x, event->y)) { Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; Sculpt *sd = CTX_data_tool_settings(C)->sculpt; @@ -3604,22 +3605,15 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) { - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - SculptSession *ss = CTX_data_active_object(C)->sculpt; - if(!sculpt_brush_stroke_init(C, op->reports)) return OPERATOR_CANCELLED; op->customdata = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start, sculpt_stroke_update_step, sculpt_stroke_done, 0); - sculpt_update_cache_invariants(C, sd, ss, op, NULL); - + /* frees op->customdata */ paint_stroke_exec(C, op); - sculpt_flush_update(C); - sculpt_cache_free(ss->cache); - return OPERATOR_FINISHED; } |