Fix #147653: Deleting a scene while playing it back causes a crash
The `ScreenAnimData` which is saved to the animation timer on the screen during playback stores a pointer to the scene that is playing. When deleting a scene, the next time the timer is triggered this will result in an invalid pointer de-reference. This fixes the crash by stopping the playback when a scene is deleted. Pull Request: https://projects.blender.org/blender/blender/pulls/147687
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -94,6 +94,14 @@ bool ED_scene_delete(bContext *C, Main *bmain, Scene *scene)
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(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<ScreenAnimData *>(screen->animtimer->customdata);
|
||||
if (sad->scene == scene) {
|
||||
ED_screen_animation_play(C, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (scene->id.prev) {
|
||||
scene_new = static_cast<Scene *>(scene->id.prev);
|
||||
}
|
||||
|
||||
@@ -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<wmWindowManager *>(bmain->wm.first);
|
||||
|
||||
/* Cancel animation playback. */
|
||||
if (bScreen *screen = ED_screen_animation_playing(wm)) {
|
||||
ScreenAnimData *sad = static_cast<ScreenAnimData *>(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
|
||||
|
||||
Reference in New Issue
Block a user