diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-13 17:47:13 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-13 17:47:13 +0400 |
commit | 807ad1f0e0de49711d58ade2b660e74ec5452b2b (patch) | |
tree | 06989f02b2a73b64cb89e28d79a294ac357c4206 /source/blender/editors/space_image/image_draw.c | |
parent | a5e6d73d412146cf9cdd077aec0b71cb615dd361 (diff) |
Fix #32087: Crash while changing values in comp editor (bt and blender included)
Issue was caused by threading conflict between compositor output node which
is freeing buffers used by render result image and image draw code which
could use buffers at the same time as compositor frees this buffers.
Solved by adding adding lock around viewer image invalidation and image
drawing.
Use renamed LOCK_PREVIEW mutex for this, which si not called LOCK_DRAW_IMAGE.
With new compositor locking for preview is not needed so it could be removed.
Added the same lock around viewer operation which also frees buffers used
by viewer image. It's actually quite difficult to check whether this is
indeed needed. This code seems to be using acquire/release technique, but
somehow acquiring ImBuf before invalidating it in compositor operation
doesn't resolve the issue, so probably it's not actually locking acquire
and things should be checked deeper.
Diffstat (limited to 'source/blender/editors/space_image/image_draw.c')
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index ac71eb972f6..88eb280ea6b 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -728,11 +728,21 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) /* retrieve the image and information about it */ ima = ED_space_image(sima); ED_space_image_zoom(sima, ar, &zoomx, &zoomy); - ibuf = ED_space_image_acquire_buffer(sima, &lock); show_viewer = (ima && ima->source == IMA_SRC_VIEWER); show_render = (show_viewer && ima->type == IMA_TYPE_R_RESULT); + if (show_viewer) { + /* use locked draw for drawing viewer image buffer since the conpositor + * is running in separated thread and compositor could free this buffers. + * other images are not modifying in such a way so they does not require + * lock (sergey) + */ + BLI_lock_thread(LOCK_DRAW_IMAGE); + } + + ibuf = ED_space_image_acquire_buffer(sima, &lock); + /* draw the image or grid */ if (ibuf == NULL) ED_region_grid_draw(ar, zoomx, zoomy); @@ -770,5 +780,8 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) /* render info */ if (ima && show_render) draw_render_info(scene, ima, ar); -} + if (show_viewer) { + BLI_unlock_thread(LOCK_DRAW_IMAGE); + } +} |