Fix T74296: Free depsgraph when view layer is removed

Reviewers: sergey

Differential Revision: https://developer.blender.org/D7110
This commit is contained in:
Jacques Lucke 2020-03-11 14:18:22 +01:00
parent 6eeaecdd67
commit 836b99ce49
Notes: blender-bot 2023-02-14 10:32:59 +01:00
Referenced by issue #74296, View layer copy consumes a lot of RAM
3 changed files with 11 additions and 0 deletions

View File

@ -215,6 +215,7 @@ int BKE_scene_multiview_num_videos_get(const struct RenderData *rd);
void BKE_scene_allocate_depsgraph_hash(struct Scene *scene);
void BKE_scene_ensure_depsgraph_hash(struct Scene *scene);
void BKE_scene_free_depsgraph_hash(struct Scene *scene);
void BKE_scene_free_view_layer_depsgraph(struct Scene *scene, struct ViewLayer *view_layer);
struct Depsgraph *BKE_scene_get_depsgraph(struct Main *bmain,
struct Scene *scene,

View File

@ -2057,6 +2057,14 @@ void BKE_scene_free_depsgraph_hash(Scene *scene)
scene->depsgraph_hash = NULL;
}
void BKE_scene_free_view_layer_depsgraph(Scene *scene, ViewLayer *view_layer)
{
if (scene->depsgraph_hash != NULL) {
DepsgraphKey key = {view_layer};
BLI_ghash_remove(scene->depsgraph_hash, &key, depsgraph_key_free, depsgraph_key_value_free);
}
}
/* Query depsgraph for a specific contexts. */
Depsgraph *BKE_scene_get_depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, bool allocate)

View File

@ -182,6 +182,8 @@ bool ED_scene_view_layer_delete(Main *bmain, Scene *scene, ViewLayer *layer, Rep
}
}
BKE_scene_free_view_layer_depsgraph(scene, layer);
BKE_view_layer_free(layer);
DEG_id_tag_update(&scene->id, 0);