[Bf-blender-cvs] [ad3f9c6dfe0] blender-v2.81-release: Fix crash drawing the paint cursor over the redo region

Campbell Barton noreply at git.blender.org
Thu Oct 24 16:27:11 CEST 2019


Commit: ad3f9c6dfe0f8e061594c856b9b16ac4dfee8cc7
Author: Campbell Barton
Date:   Fri Oct 25 01:25:23 2019 +1100
Branches: blender-v2.81-release
https://developer.blender.org/rBad3f9c6dfe0f8e061594c856b9b16ac4dfee8cc7

Fix crash drawing the paint cursor over the redo region

Also fix CTX_wm_region_view3d which didn't check the region type.

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

M	source/blender/blenkernel/intern/context.c
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/sculpt_paint/paint_image.c
M	source/blender/editors/sculpt_paint/paint_intern.h

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

diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 7f2f04d7eb5..2e4f756ce68 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -758,7 +758,7 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C)
   ARegion *ar = CTX_wm_region(C);
 
   if (sa && sa->spacetype == SPACE_VIEW3D) {
-    if (ar) {
+    if (ar && ar->regiontype == RGN_TYPE_WINDOW) {
       return ar->regiondata;
     }
   }
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index c59ab6279cd..385e37f7d22 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -1224,9 +1224,13 @@ static bool paint_use_2d_cursor(ePaintMode mode)
 
 static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
 {
+  ARegion *ar = CTX_wm_region(C);
+  if (ar && ar->regiontype != RGN_TYPE_WINDOW) {
+    return;
+  }
+
   Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
   Scene *scene = CTX_data_scene(C);
-  ARegion *ar = CTX_wm_region(C);
   UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
   Paint *paint = BKE_paint_get_active_from_context(C);
   Brush *brush = BKE_paint_brush(paint);
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index b4388f6c324..9acc189ae95 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -759,17 +759,14 @@ void PAINT_OT_image_paint(wmOperatorType *ot)
   paint_stroke_operator_properties(ot);
 }
 
-int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
+bool get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
 {
-  RegionView3D *rv3d = CTX_wm_region_view3d(C);
-
-  if (!rv3d) {
-    SpaceImage *sima = CTX_wm_space_image(C);
-
+  ScrArea *sa = CTX_wm_area(C);
+  if (sa && sa->spacetype == SPACE_IMAGE) {
+    SpaceImage *sima = sa->spacedata.first;
     if (sima->mode == SI_MODE_PAINT) {
       ARegion *ar = CTX_wm_region(C);
       ED_space_image_get_zoom(sima, ar, zoomx, zoomy);
-
       return 1;
     }
   }
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 19380fb9022..84665728e17 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -191,7 +191,7 @@ struct ImagePaintPartialRedraw *get_imapaintpartial(void);
 void set_imapaintpartial(struct ImagePaintPartialRedraw *ippr);
 void imapaint_region_tiles(
     struct ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th);
-int get_imapaint_zoom(struct bContext *C, float *zoomx, float *zoomy);
+bool get_imapaint_zoom(struct bContext *C, float *zoomx, float *zoomy);
 void *paint_2d_new_stroke(struct bContext *, struct wmOperator *, int mode);
 void paint_2d_redraw(const struct bContext *C, void *ps, bool final);
 void paint_2d_stroke_done(void *ps);



More information about the Bf-blender-cvs mailing list