[Bf-blender-cvs] [5d4574ea0e7] master: Fix T99340: Image.frame_duration returning wrong value when image not loaded

Brecht Van Lommel noreply at git.blender.org
Wed Jul 20 19:04:56 CEST 2022


Commit: 5d4574ea0e7a010c130f1728408f198886ea5c44
Author: Brecht Van Lommel
Date:   Wed Jul 20 18:19:37 2022 +0200
Branches: master
https://developer.blender.org/rB5d4574ea0e7a010c130f1728408f198886ea5c44

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.

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

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 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;
 }



More information about the Bf-blender-cvs mailing list