Fix wrong sculpt cursor drawing when using "ignore_background_click"

Not all the necessary state got restored.
This commit is contained in:
Brecht Van Lommel 2019-09-28 23:32:51 +02:00
parent ba90d2efa5
commit c31a849a14
Notes: blender-bot 2023-02-14 06:49:57 +01:00
Referenced by commit 31473070b3, Fix T70443: Crash on sculpting with 'Curve' Stroke Method
Referenced by issue #70443, Crash on sculpting with 'Curve' Stroke Method
5 changed files with 32 additions and 29 deletions

View File

@ -700,7 +700,7 @@ static int paint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
event->type);
if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
paint_stroke_data_free(op);
paint_stroke_free(C, op);
return OPERATOR_FINISHED;
}
/* add modal handler */

View File

@ -70,7 +70,7 @@ struct PaintStroke *paint_stroke_new(struct bContext *C,
StrokeRedraw redraw,
StrokeDone done,
int event_type);
void paint_stroke_data_free(struct wmOperator *op);
void paint_stroke_free(struct bContext *C, struct wmOperator *op);
bool paint_space_stroke_enabled(struct Brush *br, enum ePaintMode mode);
bool paint_supports_dynamic_size(struct Brush *br, enum ePaintMode mode);

View File

@ -901,20 +901,37 @@ PaintStroke *paint_stroke_new(bContext *C,
return stroke;
}
void paint_stroke_data_free(struct wmOperator *op)
void paint_stroke_free(bContext *C, wmOperator *op)
{
BKE_paint_set_overlay_override(0);
MEM_SAFE_FREE(op->customdata);
}
static void stroke_done(struct bContext *C, struct wmOperator *op)
{
struct PaintStroke *stroke = op->customdata;
PaintStroke *stroke = op->customdata;
UnifiedPaintSettings *ups = stroke->ups;
ups->draw_anchored = false;
ups->stroke_active = false;
if (stroke->timer) {
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), stroke->timer);
}
if (stroke->rng) {
BLI_rng_free(stroke->rng);
}
if (stroke->stroke_cursor) {
WM_paint_cursor_end(CTX_wm_manager(C), stroke->stroke_cursor);
}
BLI_freelistN(&stroke->line);
BKE_paint_set_overlay_override(0);
MEM_SAFE_FREE(op->customdata);
}
static void stroke_done(bContext *C, wmOperator *op)
{
PaintStroke *stroke = op->customdata;
UnifiedPaintSettings *ups = stroke->ups;
/* reset rotation here to avoid doing so in cursor display */
if (!(stroke->brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) {
ups->brush_rotation = 0.0f;
@ -934,21 +951,7 @@ static void stroke_done(struct bContext *C, struct wmOperator *op)
}
}
if (stroke->timer) {
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), stroke->timer);
}
if (stroke->rng) {
BLI_rng_free(stroke->rng);
}
if (stroke->stroke_cursor) {
WM_paint_cursor_end(CTX_wm_manager(C), stroke->stroke_cursor);
}
BLI_freelistN(&stroke->line);
paint_stroke_data_free(op);
paint_stroke_free(C, op);
}
/* Returns zero if the stroke dots should not be spaced, non-zero otherwise */

View File

@ -2439,7 +2439,7 @@ static int wpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
event->type);
if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
paint_stroke_data_free(op);
paint_stroke_free(C, op);
return OPERATOR_FINISHED;
}
/* add modal handler */
@ -3381,7 +3381,7 @@ static int vpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
event->type);
if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
paint_stroke_data_free(op);
paint_stroke_free(C, op);
return OPERATOR_FINISHED;
}

View File

@ -7004,12 +7004,12 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent
ignore_background_click = RNA_boolean_get(op->ptr, "ignore_background_click");
if (ignore_background_click && !over_mesh(C, op, event->x, event->y)) {
paint_stroke_data_free(op);
paint_stroke_free(C, op);
return OPERATOR_PASS_THROUGH;
}
if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
paint_stroke_data_free(op);
paint_stroke_free(C, op);
return OPERATOR_FINISHED;
}
/* add modal handler */