Fix: Crash when snapping to first key using subframes
When pressing Ctrl to snap the playhead while scrubbing, Blender could crash while trying to snap to the first key. This would happen if the current frame was higher than the left keyframe, but the difference was less than the `BEZT_BINARYSEARCH_THRESH`. Pull Request: https://projects.blender.org/blender/blender/pulls/140122
This commit is contained in:
committed by
Christoph Lendenfeld
parent
633463c586
commit
27d2d0a23a
@@ -274,10 +274,12 @@ const ActKeyColumn *ED_keylist_find_closest(const AnimKeylist *keylist, const fl
|
||||
if (ED_keylist_is_empty(keylist)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (cfra <= keylist->runtime.key_columns.first().cfra) {
|
||||
/* Need to check against BEZT_BINARYSEARCH_THRESH because `ED_keylist_find_prev` does so as well.
|
||||
* Not doing that here could cause that function to return a nullptr. */
|
||||
if (cfra - keylist->runtime.key_columns.first().cfra < BEZT_BINARYSEARCH_THRESH) {
|
||||
return &keylist->runtime.key_columns.first();
|
||||
}
|
||||
if (cfra >= keylist->runtime.key_columns.last().cfra) {
|
||||
if (cfra - keylist->runtime.key_columns.last().cfra > BEZT_BINARYSEARCH_THRESH) {
|
||||
keylist->runtime.key_columns.last();
|
||||
}
|
||||
const ActKeyColumn *prev = ED_keylist_find_prev(keylist, cfra);
|
||||
|
||||
Reference in New Issue
Block a user