diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-07-20 19:19:37 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-07-20 19:23:03 +0300 |
commit | 5d4574ea0e7a010c130f1728408f198886ea5c44 (patch) | |
tree | a463cf1ad5fc3ffd44cb66f800bfadb35345a83d /source/blender/makesrna/intern/rna_image.c | |
parent | c4d8e28aa7043d7b7774d5b88ef454ba4d3e81ce (diff) |
Fix T99340: Image.frame_duration returning wrong value when image not loaded
The logic here was broken in d5f1b9c, it should load the image first.
Diffstat (limited to 'source/blender/makesrna/intern/rna_image.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 39f5b6e0e9f..7f134c5055f 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -475,18 +475,19 @@ static int rna_Image_frame_duration_get(PointerRNA *ptr) Image *ima = (Image *)ptr->owner_id; int duration = 1; + if (!BKE_image_has_anim(ima)) { + /* Ensure image has been loaded into memory and frame duration is known. */ + void *lock; + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); + BKE_image_release_ibuf(ima, ibuf, lock); + } + if (BKE_image_has_anim(ima)) { struct anim *anim = ((ImageAnim *)ima->anims.first)->anim; if (anim) { duration = IMB_anim_get_duration(anim, IMB_TC_RECORD_RUN); } } - else { - /* acquire ensures ima->anim is set, if possible! */ - void *lock; - ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); - BKE_image_release_ibuf(ima, ibuf, lock); - } return duration; } |