Fix T64867: crash when changin image source to Movie
authorPhilipp Oeser <info@graphics-engineer.com>
Mon, 20 May 2019 11:43:25 +0000 (13:43 +0200)
committerPhilipp Oeser <info@graphics-engineer.com>
Tue, 21 May 2019 07:34:00 +0000 (09:34 +0200)
thx @Gvgeo for adding the python/RNA case as well.

Reviewers: brecht

Maniphest Tasks: T64867

Differential Revision: https://developer.blender.org/D4902

source/blender/editors/space_image/image_buttons.c
source/blender/makesrna/intern/rna_image.c

index 8fada528f48f4d7f7a863e724e65afd6d1e2942e..b32f5ef6d9e596c2e6e6a2c56113cdbf1f60e06e 100644 (file)
@@ -1254,7 +1254,10 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
     int duration = 0;
 
     if (ima->source == IMA_SRC_MOVIE && BKE_image_has_anim(ima)) {
-      duration = IMB_anim_get_duration(((ImageAnim *)ima->anims.first)->anim, IMB_TC_RECORD_RUN);
+      struct anim *anim = ((ImageAnim *)ima->anims.first)->anim;
+      if (anim) {
+        duration = IMB_anim_get_duration(anim, IMB_TC_RECORD_RUN);
+      }
     }
 
     if (duration > 0) {
index 11abe9684701bcd9a5e36f2cd5cca500431985de..7f2eccf421e474e724f8621719272ea743e295ce 100644 (file)
@@ -332,7 +332,10 @@ static int rna_Image_frame_duration_get(PointerRNA *ptr)
   int duration = 1;
 
   if (BKE_image_has_anim(ima)) {
-    duration = IMB_anim_get_duration(((ImageAnim *)ima->anims.first)->anim, IMB_TC_RECORD_RUN);
+    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! */