diff --git a/source/blender/editors/animation/anim_draw.cc b/source/blender/editors/animation/anim_draw.cc index 5cf72f71021..8cd232432c7 100644 --- a/source/blender/editors/animation/anim_draw.cc +++ b/source/blender/editors/animation/anim_draw.cc @@ -129,7 +129,7 @@ void ANIM_draw_scene_strip_range(const bContext *C, View2D *v2d) return; } const Strip *scene_strip = blender::ed::vse::get_scene_strip_for_time_sync(sequencer_scene); - if (!scene_strip) { + if (!scene_strip || !scene_strip->scene) { return; } GPU_blend(GPU_BLEND_ALPHA); diff --git a/source/blender/editors/scene/scene_edit.cc b/source/blender/editors/scene/scene_edit.cc index b9f75b0504c..ea44264590e 100644 --- a/source/blender/editors/scene/scene_edit.cc +++ b/source/blender/editors/scene/scene_edit.cc @@ -94,6 +94,14 @@ bool ED_scene_delete(bContext *C, Main *bmain, Scene *scene) wmWindowManager *wm = static_cast(bmain->wm.first); WM_jobs_kill_all_from_owner(wm, scene); + /* Cancel animation playback. */ + if (bScreen *screen = ED_screen_animation_playing(CTX_wm_manager(C))) { + ScreenAnimData *sad = static_cast(screen->animtimer->customdata); + if (sad->scene == scene) { + ED_screen_animation_play(C, 0, 0); + } + } + if (scene->id.prev) { scene_new = static_cast(scene->id.prev); } diff --git a/source/blender/makesrna/intern/rna_main_api.cc b/source/blender/makesrna/intern/rna_main_api.cc index a5d65d31496..6f3db9533e0 100644 --- a/source/blender/makesrna/intern/rna_main_api.cc +++ b/source/blender/makesrna/intern/rna_main_api.cc @@ -205,6 +205,23 @@ static void rna_Main_scenes_remove( /* Don't rely on `CTX_wm_window(C)` as it may have been cleared, * yet windows may still be open that reference this scene. */ wmWindowManager *wm = static_cast(bmain->wm.first); + + /* Cancel animation playback. */ + if (bScreen *screen = ED_screen_animation_playing(wm)) { + ScreenAnimData *sad = static_cast(screen->animtimer->customdata); + if (sad->scene == scene) { +# ifdef WITH_PYTHON + BPy_BEGIN_ALLOW_THREADS; +# endif + + ED_screen_animation_play(C, 0, 0); + +# ifdef WITH_PYTHON + BPy_END_ALLOW_THREADS; +# endif + } + } + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (WM_window_get_active_scene(win) == scene) { # ifdef WITH_PYTHON