Fix #147483: Crash switching scene while rendering animation in main window
When rendering in the main window and changing the active scene, RE_FreeUnusedGPUResources can free the resources of an active Render, since no wmWindow references the Scene anymore. Active Render instances always reference their Scene, so we check those directly instead. Pull Request: https://projects.blender.org/blender/blender/pulls/147553
This commit is contained in:
@@ -684,20 +684,24 @@ void RE_FreeUnusedGPUResources()
|
|||||||
for (Render *re : RenderGlobal.render_list) {
|
for (Render *re : RenderGlobal.render_list) {
|
||||||
bool do_free = true;
|
bool do_free = true;
|
||||||
|
|
||||||
|
const Scene *scene = RE_GetScene(re);
|
||||||
|
/* Don't free scenes being rendered or composited. Note there is no
|
||||||
|
* race condition here because we are on the main thread and new jobs can only
|
||||||
|
* be started from the main thread. */
|
||||||
|
if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER) ||
|
||||||
|
WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE))
|
||||||
|
{
|
||||||
|
do_free = false;
|
||||||
|
}
|
||||||
|
|
||||||
LISTBASE_FOREACH (const wmWindow *, win, &wm->windows) {
|
LISTBASE_FOREACH (const wmWindow *, win, &wm->windows) {
|
||||||
const Scene *scene = WM_window_get_active_scene(win);
|
if (!do_free) {
|
||||||
if (re != RE_GetSceneRender(scene)) {
|
/* No need to do further checks. */
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't free if this scene is being rendered or composited. Note there is no
|
if (WM_window_get_active_scene(win) != scene) {
|
||||||
* race condition here because we are on the main thread and new jobs can only
|
continue;
|
||||||
* be started from the main thread. */
|
|
||||||
if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER) ||
|
|
||||||
WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE))
|
|
||||||
{
|
|
||||||
do_free = false;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Detect if scene is using GPU compositing, and if either a node editor is
|
/* Detect if scene is using GPU compositing, and if either a node editor is
|
||||||
|
|||||||
Reference in New Issue
Block a user