From 49b1a319c44f0ac3db45652f4cb022d2e1a93d40 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 13 Oct 2011 03:35:08 +0000 Subject: fix [#28898] Segmentation fault when Home key during GreasePencil dopesheet pressed --- source/blender/editors/space_action/action_edit.c | 38 +++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index a05053a2d9d..7bf0f98b471 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -246,20 +246,32 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max, cons /* go through channels, finding max extents */ for (ale= anim_data.first; ale; ale= ale->next) { AnimData *adt= ANIM_nla_mapping_get(ac, ale); - FCurve *fcu= (FCurve *)ale->key_data; - float tmin, tmax; - - /* get range and apply necessary scaling before processing */ - calc_fcurve_range(fcu, &tmin, &tmax, onlySel); - - if (adt) { - tmin= BKE_nla_tweakedit_remap(adt, tmin, NLATIME_CONVERT_MAP); - tmax= BKE_nla_tweakedit_remap(adt, tmax, NLATIME_CONVERT_MAP); + if (ale->datatype == ALE_GPFRAME) { + bGPDlayer *gpl= ale->data; + bGPDframe *gpf; + + /* find gp-frame which is less than or equal to cframe */ + for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + *min= MIN2(*min, gpf->framenum); + *max= MAX2(*max, gpf->framenum); + } + } + else { + FCurve *fcu= (FCurve *)ale->key_data; + float tmin, tmax; + + /* get range and apply necessary scaling before processing */ + calc_fcurve_range(fcu, &tmin, &tmax, onlySel); + + if (adt) { + tmin= BKE_nla_tweakedit_remap(adt, tmin, NLATIME_CONVERT_MAP); + tmax= BKE_nla_tweakedit_remap(adt, tmax, NLATIME_CONVERT_MAP); + } + + /* try to set cur using these values, if they're more extreme than previously set values */ + *min= MIN2(*min, tmin); + *max= MAX2(*max, tmax); } - - /* try to set cur using these values, if they're more extreme than previously set values */ - *min= MIN2(*min, tmin); - *max= MAX2(*max, tmax); } /* free memory */ -- cgit v1.2.3