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!
This commit is contained in:
Bastien Montagne 2015-01-02 22:49:00 +01:00
parent 1369bd562c
commit 8a288953cc
Notes: blender-bot 2023-02-14 10:02:29 +01:00
Referenced by issue #43204, Bone shrinkwrap constraint in project mode does not respect pose space; acts in bone's local space
Referenced by issue #43128, Possibility to move a panel above first headerless one, in Physics buttons?
Referenced by issue #43118, GPU renders using .hdr environment maps fail with error
Referenced by issue #43122, Shrinkwrap modifier confusion on linked meshes
Referenced by issue #43113, Some System Folders do not contain go back arrow
Referenced by issue #43114, Go back still seem like it should be select able
Referenced by issue #41964, 2.72 Freestyle renders two times longer on Linux
1 changed files with 14 additions and 4 deletions

View File

@ -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 (im->anim)
return IMB_anim_get_duration(im->anim, IMB_TC_RECORD_RUN);
return 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);
}
return duration;
}
static int rna_Image_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])