diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2019-12-16 14:41:53 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2019-12-16 14:41:53 +0300 |
commit | bbc97fc533d03a7242d3172a6780794a28e20e7e (patch) | |
tree | 019e6ab31c03112c53d7305175f9cbd8b13f630c /source/blender/editors/sculpt_paint | |
parent | 01608f53480a4ce1c91e88b92a507a04878f5654 (diff) |
Fix T72440: Dragging & dropping color in the Image Editor crashes
This was caused by a call to paint_2d_bucket_fill that I missed in the
UDIM changes.
Now, this feature does not only not crash, but it even works with tiled
images!
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_2d.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 06d79b8a49d..bf198f70a67 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -1560,9 +1560,9 @@ static void paint_2d_canvas_free(ImagePaintState *s) } } -static void paint_2d_transform_mouse(ImagePaintState *s, const float in[2], float out[2]) +static void paint_2d_transform_mouse(View2D *v2d, const float in[2], float out[2]) { - UI_view2d_region_to_view(s->v2d, in[0], in[1], &out[0], &out[1]); + UI_view2d_region_to_view(v2d, in[0], in[1], &out[0], &out[1]); } static bool is_inside_tile(const int size[2], const float pos[2], const float brush[2]) @@ -1899,14 +1899,24 @@ void paint_2d_bucket_fill(const bContext *C, return; } + View2D *v2d = s ? s->v2d : &CTX_wm_region(C)->v2d; float uv_origin[2]; float image_init[2]; - paint_2d_transform_mouse(s, mouse_init, image_init); + paint_2d_transform_mouse(v2d, mouse_init, image_init); int tile_number = BKE_image_get_tile_from_pos(ima, image_init, image_init, uv_origin); - ImageUser *iuser = paint_2d_get_tile_iuser(s, tile_number); - if (!iuser) { - return; + + ImageUser local_iuser, *iuser; + if (s != NULL) { + iuser = paint_2d_get_tile_iuser(s, tile_number); + if (iuser == NULL) { + return; + } + } + else { + iuser = &local_iuser; + BKE_imageuser_default(iuser); + iuser->tile = tile_number; } ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); @@ -2125,8 +2135,8 @@ void paint_2d_gradient_fill( return; } - paint_2d_transform_mouse(s, mouse_final, image_final); - paint_2d_transform_mouse(s, mouse_init, image_init); + paint_2d_transform_mouse(s->v2d, mouse_final, image_final); + paint_2d_transform_mouse(s->v2d, mouse_init, image_init); sub_v2_v2(image_init, uv_origin); sub_v2_v2(image_final, uv_origin); |