[Bf-blender-cvs] [8a28895] master: Fix RNA Image.frame_duration.

Bastien Montagne noreply at git.blender.org
Fri Jan 2 22:52:36 CET 2015


Commit: 8a288953cc1dfa2b6e03b3cce31083399a451ba6
Author: Bastien Montagne
Date:   Fri Jan 2 22:49:00 2015 +0100
Branches: master
https://developer.blender.org/rB8a288953cc1dfa2b6e03b3cce31083399a451ba6

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!

===================================================================

M	source/blender/makesrna/intern/rna_image.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 141de51..397e03a 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])




More information about the Bf-blender-cvs mailing list