Fix wrong sculpt cursor drawing when using "ignore_background_click"
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sat, 28 Sep 2019 21:32:51 +0000 (23:32 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 29 Sep 2019 13:04:10 +0000 (15:04 +0200)
Not all the necessary state got restored.

source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_intern.h
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c

index e066e101410e67c7049feb6e7360e00ae2c6b141..54531139616c1bb088c29747a299c400678168ac 100644 (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 */
index 8be474880a526e82b1d560ed1a7e91d9c00b8ffc..abfa43319525e66fe527d3f810300a4dbf954cbb 100644 (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);
index 51296fa5d44273a116424f8c0fb8f92947e13f84..137d7bd9d6caca798186b447731c47371748b443 100644 (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)
 {
+  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(struct bContext *C, struct wmOperator *op)
+static void stroke_done(bContext *C, wmOperator *op)
 {
-  struct PaintStroke *stroke = op->customdata;
+  PaintStroke *stroke = op->customdata;
   UnifiedPaintSettings *ups = stroke->ups;
 
-  ups->draw_anchored = false;
-  ups->stroke_active = false;
-
   /* 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 */
index a171caeca6a86a8bb3fe45304ea7fade006cb709..9887f598f42b40d785fc0aeb0e89c740e34cbf15 100644 (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;
   }
 
index 2309f151feeac27c2154c368358c9542b9ec5dff..51ca0ec3403ae93004280b8f4ddca037e5e89354 100644 (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 */