Fix T52058: Jumping to keyframe causes Blender to freeze indefinitely

Revise the logic here to be more robust when keyframes with
similar-but-different frame numbers (e.g. 70.000000 vs 70.000008)
would cause the search to go into an infinite loop, as the same
keyframe was repeatedly found (and skipped).
This commit is contained in:
Joshua Leung 2017-07-17 02:24:45 +12:00
parent 5c30bc285c
commit 7021aa245d
Notes: blender-bot 2023-02-14 08:45:12 +01:00
Referenced by issue #52058, Jumping to keyframe causes Blender to freeze indefinitely
1 changed files with 18 additions and 15 deletions

View File

@ -2260,25 +2260,28 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
BLI_dlrbTree_linkedlist_sync(&keys);
/* find matching keyframe in the right direction */
do {
if (next)
ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
else
ak = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra);
if (ak) {
if (CFRA != (int)ak->cfra) {
/* this changes the frame, so set the frame and we're done */
CFRA = (int)ak->cfra;
done = true;
if (next)
ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
else
ak = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra);
while ((ak != NULL) && (done == false)) {
if (CFRA != (int)ak->cfra) {
/* this changes the frame, so set the frame and we're done */
CFRA = (int)ak->cfra;
done = true;
}
else {
/* take another step... */
if (next) {
ak = ak->next;
}
else {
/* make this the new starting point for the search */
cfra = ak->cfra;
ak = ak->prev;
}
}
} while ((ak != NULL) && (done == false));
}
/* free temp stuff */
BLI_dlrbTree_free(&keys);