Fix: Try to mitigate frame sync race condition when stopping playback
We would update the scene frame before we actually stopped the callback timers for automatic frame sync. This could lead to a race condition where the set frame would be overwritten before we stopped the callback timer. Pull Request: https://projects.blender.org/blender/blender/pulls/132022
This commit is contained in:
@@ -5767,20 +5767,21 @@ static int screen_animation_cancel_exec(bContext *C, wmOperator *op)
|
||||
bScreen *screen = ED_screen_animation_playing(CTX_wm_manager(C));
|
||||
|
||||
if (screen) {
|
||||
if (RNA_boolean_get(op->ptr, "restore_frame") && screen->animtimer) {
|
||||
bool restore_start_frame = RNA_boolean_get(op->ptr, "restore_frame") && screen->animtimer;
|
||||
int frame;
|
||||
if (restore_start_frame) {
|
||||
ScreenAnimData *sad = static_cast<ScreenAnimData *>(screen->animtimer->customdata);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
/* reset current frame before stopping, and just send a notifier to deal with the rest
|
||||
* (since playback still needs to be stopped)
|
||||
*/
|
||||
scene->r.cfra = sad->sfra;
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
||||
frame = sad->sfra;
|
||||
}
|
||||
|
||||
/* call the other "toggling" operator to clean up now */
|
||||
/* Stop playback */
|
||||
ED_screen_animation_play(C, 0, 0);
|
||||
if (restore_start_frame) {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
/* reset current frame and just send a notifier to deal with the rest */
|
||||
scene->r.cfra = frame;
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
||||
}
|
||||
}
|
||||
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
|
||||
Reference in New Issue
Block a user