From d376aea61840587eddcf75386b804673e5593d60 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 16 Sep 2020 11:53:55 +0200 Subject: Fix: Showing Meta Data Crash When Showing Meta data for an image where the buffer does not exist (missing file) it crashed. This patch removes the check on the image and only checks the availability of the buffer. --- source/blender/editors/space_image/space_image.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 5660320ae8a..1d23a409748 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -673,19 +673,17 @@ static void image_main_region_draw(const bContext *C, ARegion *region) /* Draw Meta data of the image isn't added to the DrawManager as it is * used in other areas as well. */ if (sima->flag & SI_DRAW_METADATA) { - Image *ima = ED_space_image(sima); - if (ima != NULL) { + void *lock; + /* `ED_space_image_get_zoom` temporarily locks the image, so this needs to be done before + * the image is locked when calling `ED_space_image_acquire_buffer`. */ + float zoomx, zoomy; + ED_space_image_get_zoom(sima, region, &zoomx, &zoomy); + ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, 0); + if (ibuf) { int x, y; rctf frame; - float zoomx, zoomy; - void *lock; - - ED_space_image_get_zoom(sima, region, &zoomx, &zoomy); - ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, 0); - BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y); UI_view2d_view_to_region(®ion->v2d, 0.0f, 0.0f, &x, &y); - ED_region_image_metadata_draw(x, y, ibuf, &frame, zoomx, zoomy); ED_space_image_release_buffer(sima, ibuf, lock); } -- cgit v1.2.3