diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-11-10 16:02:28 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-11-10 16:02:28 +0300 |
commit | 2a2bc090960695e2fc1e701b016126e5e8cc595a (patch) | |
tree | fe7f9c5bf68b0f214bdc7a6f3ff1492dd36eff99 /source/blender | |
parent | 23c71a5fab42e22266196a45f1f2ac77e815bcd3 (diff) | |
parent | 4960780d76bf5a157404cfa5b126cd8ab87caec8 (diff) |
Merge remote-tracking branch 'origin/blender-v2.91-release'
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 47d4b70fef5..8bfc626379f 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -841,11 +841,23 @@ bool BKE_fcurve_calc_range( */ void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt) { + if (active_bezt == NULL) { + fcu->active_keyframe_index = FCURVE_ACTIVE_KEYFRAME_NONE; + return; + } + + /* Gracefully handle out-of-bounds pointers. Ideally this would do a BLI_assert() as well, but + * then the unit tests would break in debug mode. */ + ptrdiff_t offset = active_bezt - fcu->bezt; + if (offset < 0 || offset >= fcu->totvert) { + fcu->active_keyframe_index = FCURVE_ACTIVE_KEYFRAME_NONE; + return; + } + /* The active keyframe should always be selected. */ - BLI_assert((active_bezt == NULL) || - ((active_bezt->f1 | active_bezt->f2 | active_bezt->f3) & SELECT)); - fcu->active_keyframe_index = (active_bezt == NULL) ? FCURVE_ACTIVE_KEYFRAME_NONE : - active_bezt - fcu->bezt; + BLI_assert(BEZT_ISSEL_ANY(active_bezt)); + + fcu->active_keyframe_index = (int)offset; } /** |