NLA SoC: Fixes for crashes when selecting keyframes in object channels in DopeSheet
authorJoshua Leung <aligorith@gmail.com>
Fri, 12 Jun 2009 02:49:21 +0000 (02:49 +0000)
committerJoshua Leung <aligorith@gmail.com>
Fri, 12 Jun 2009 02:49:21 +0000 (02:49 +0000)
source/blender/editors/animation/anim_filter.c
source/blender/editors/animation/keyframes_edit.c
source/blender/editors/space_action/action_select.c

index b47211f35d14f1143cdb5ffc6509e981646fe0bf..f9c1b1bb42fc865dee3ef323e278cd4b2c12c3fb 100644 (file)
@@ -1095,17 +1095,6 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
                ANIMDATA_FILTER_CASES(ob,
                        { /* AnimData blocks - do nothing... */ },
                        { /* nla */
-#if 0
-                               /* include nla-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_NLATRACKS)) {
-                                       ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLNLA, base, ANIMTYPE_OBJECT, (ID *)ob);
-                                       if (ale) {
-                                               BLI_addtail(anim_data, ale);
-                                               items++;
-                                       }
-                               }
-#endif
-                               
                                /* add NLA tracks */
                                items += animdata_filter_nla(anim_data, adt, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
                        },
@@ -1141,7 +1130,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
                                        items += animdata_filter_action(anim_data, adt->action, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob); 
                                }
                        }
-               )
+               );
        }
        
        
@@ -1151,17 +1140,6 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
                ANIMDATA_FILTER_CASES(key,
                        { /* AnimData blocks - do nothing... */ },
                        { /* nla */
-#if 0
-                               /* include nla-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_NLATRACKS)) {
-                                       ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLNLA, base, ANIMTYPE_OBJECT, (ID *)ob);
-                                       if (ale) {
-                                               BLI_addtail(anim_data, ale);
-                                               items++;
-                                       }
-                               }
-#endif
-                               
                                /* add NLA tracks */
                                items += animdata_filter_nla(anim_data, adt, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
                        },
@@ -1195,7 +1173,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
                                        items += animdata_filter_shapekey(anim_data, key, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
                                }
                        }
-               )
+               );
        }
 
        /* Materials? */
@@ -1280,17 +1258,6 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads
                ANIMDATA_FILTER_CASES(sce,
                        { /* AnimData blocks - do nothing... */ },
                        { /* nla */
-#if 0
-                               /* include nla-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_NLATRACKS)) {
-                                       ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLNLA, base, ANIMTYPE_SCENE (ID *)sce);
-                                       if (ale) {
-                                               BLI_addtail(anim_data, ale);
-                                               items++;
-                                       }
-                               }
-#endif
-                               
                                /* add NLA tracks */
                                items += animdata_filter_nla(anim_data, adt, filter_mode, sce, ANIMTYPE_SCENE, (ID *)sce);
                        },
@@ -1334,17 +1301,6 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads
                ANIMDATA_FILTER_CASES(wo,
                        { /* AnimData blocks - do nothing... */ },
                        { /* nla */
-#if 0
-                               /* include nla-expand widget? */
-                               if ((filter_mode & ANIMFILTER_CHANNELS) && !(filter_mode & ANIMFILTER_NLATRACKS)) {
-                                       ale= make_new_animlistelem(adt->action, ANIMTYPE_FILLNLA, base, ANIMTYPE_DSWOR (ID *)wo);
-                                       if (ale) {
-                                               BLI_addtail(anim_data, ale);
-                                               items++;
-                                       }
-                               }
-#endif
-                               
                                /* add NLA tracks */
                                items += animdata_filter_nla(anim_data, adt, filter_mode, wo, ANIMTYPE_DSWOR, (ID *)wo);
                        },
index 8243629b4a6c9917a2a309ac2725268f4ada3745..77826eca87a7ba326e434935c112d6ad0d2c86d9 100644 (file)
@@ -128,6 +128,10 @@ static short agrp_keys_bezier_loop(BeztEditData *bed, bActionGroup *agrp, BeztEd
 {
        FCurve *fcu;
        
+       /* sanity check */
+       if (agrp == NULL)
+               return 0;
+       
        /* only iterate over the F-Curves that are in this group */
        for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) {
                if (ANIM_fcurve_keys_bezier_loop(bed, fcu, bezt_ok, bezt_cb, fcu_cb))
@@ -142,6 +146,10 @@ static short act_keys_bezier_loop(BeztEditData *bed, bAction *act, BeztEditFunc
 {
        FCurve *fcu;
        
+       /* sanity check */
+       if (act == NULL)
+               return 0;
+       
        /* just loop through all F-Curves */
        for (fcu= act->curves.first; fcu; fcu= fcu->next) {
                if (ANIM_fcurve_keys_bezier_loop(bed, fcu, bezt_ok, bezt_cb, fcu_cb))
@@ -154,6 +162,10 @@ static short act_keys_bezier_loop(BeztEditData *bed, bAction *act, BeztEditFunc
 /* This function is used to loop over the keyframe data of an AnimData block */
 static short adt_keys_bezier_loop(BeztEditData *bed, AnimData *adt, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag)
 {
+       /* sanity check */
+       if (adt == NULL)
+               return 0;
+       
        /* drivers or actions? */
        if (filterflag & ADS_FILTER_ONLYDRIVERS) {
                FCurve *fcu;
@@ -178,6 +190,10 @@ static short ob_keys_bezier_loop(BeztEditData *bed, Object *ob, BeztEditFunc bez
 {
        Key *key= ob_get_key(ob);
        
+       /* sanity check */
+       if (ob == NULL)
+               return 0;
+       
        /* firstly, Object's own AnimData */
        if (ob->adt) 
                adt_keys_bezier_loop(bed, ob->adt, bezt_ok, bezt_cb, fcu_cb, filterflag);
@@ -194,7 +210,11 @@ static short ob_keys_bezier_loop(BeztEditData *bed, Object *ob, BeztEditFunc bez
 /* This function is used to loop over the keyframe data in a Scene */
 static short scene_keys_bezier_loop(BeztEditData *bed, Scene *sce, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag)
 {
-       World *wo= sce->world;
+       World *wo= (sce) ? sce->world : NULL;
+       
+       /* sanity check */
+       if (sce == NULL)
+               return 0;
        
        /* Scene's own animation */
        if (sce->adt)
@@ -231,7 +251,7 @@ short ANIM_animchannel_keys_bezier_loop(BeztEditData *bed, bAnimListElem *ale, B
                        return act_keys_bezier_loop(bed, (bAction *)ale->data, bezt_ok, bezt_cb, fcu_cb);
                        
                case ALE_OB: /* object */
-                       return ob_keys_bezier_loop(bed, (Object *)ale->data, bezt_ok, bezt_cb, fcu_cb, filterflag);
+                       return ob_keys_bezier_loop(bed, (Object *)ale->key_data, bezt_ok, bezt_cb, fcu_cb, filterflag);
                case ALE_SCE: /* scene */
                        return scene_keys_bezier_loop(bed, (Scene *)ale->data, bezt_ok, bezt_cb, fcu_cb, filterflag);
        }
index d8ed3fd10681cdeffe8b9c1d4d342b7d1f52cfd6..826728e83f9b6b2a977360166288a6b29f477e94 100644 (file)
@@ -858,17 +858,19 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short select_mode,
                        ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
                        
                        /* Highlight Action-Group or F-Curve? */
-                       if (ale->type == ANIMTYPE_GROUP) {
-                               bActionGroup *agrp= ale->data;
-                               
-                               agrp->flag |= AGRP_SELECTED;
-                               ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
-                       }       
-                       else if (ale->type == ANIMTYPE_FCURVE) {
-                               FCurve *fcu= ale->data;
-                               
-                               fcu->flag |= FCURVE_SELECTED;
-                               ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE);
+                       if (ale && ale->data) {
+                               if (ale->type == ANIMTYPE_GROUP) {
+                                       bActionGroup *agrp= ale->data;
+                                       
+                                       agrp->flag |= AGRP_SELECTED;
+                                       ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
+                               }       
+                               else if (ale->type == ANIMTYPE_FCURVE) {
+                                       FCurve *fcu= ale->data;
+                                       
+                                       fcu->flag |= FCURVE_SELECTED;
+                                       ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE);
+                               }
                        }
                }
                else if (ac->datatype == ANIMCONT_GPENCIL) {
@@ -881,7 +883,7 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short select_mode,
        }
        
        /* only select keyframes if we clicked on a valid channel and hit something */
-       if (ale) {
+       if (ale && found) {
                /* apply selection to keyframes */
                if (/*gpl*/0) {
                        /* grease pencil */