From ad3f9c6dfe0f8e061594c856b9b16ac4dfee8cc7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Oct 2019 01:25:23 +1100 Subject: Fix crash drawing the paint cursor over the redo region Also fix CTX_wm_region_view3d which didn't check the region type. --- source/blender/blenkernel/intern/context.c | 2 +- source/blender/editors/sculpt_paint/paint_cursor.c | 6 +++++- source/blender/editors/sculpt_paint/paint_image.c | 11 ++++------- source/blender/editors/sculpt_paint/paint_intern.h | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) 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); -- cgit v1.2.3