diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-03 00:49:00 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-03 00:51:51 +0300 |
commit | 8a288953cc1dfa2b6e03b3cce31083399a451ba6 (patch) | |
tree | fb5a103cc5b79004ad969ee3d7b09e06d21e6c79 /source/blender | |
parent | 1369bd562cfe31fdec8a1755d2f0506d8373d7ad (diff) |
Fix RNA Image.frame_duration.
If a video was loaded (e.g. from python) but never 'ibuf-acquired', its Image->anim
prop would still be NULL, returning useless '1' value as frame duration!
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 141de511a09..397e03a9ee1 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -292,11 +292,21 @@ static int rna_Image_depth_get(PointerRNA *ptr) static int rna_Image_frame_duration_get(PointerRNA *ptr) { - Image *im = (Image *)ptr->data; + Image *ima = ptr->id.data; + int duration = 1; + + if (!ima->anim) { + /* 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); + } + + if (ima->anim) { + duration = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN); + } - if (im->anim) - return IMB_anim_get_duration(im->anim, IMB_TC_RECORD_RUN); - return 1; + return duration; } static int rna_Image_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) |