Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-08-19 13:32:11 +0300
committerJulian Eisel <julian@blender.org>2020-08-19 13:37:59 +0300
commit5cc08510e0a636ea99eb753cb0ff65861d5e4813 (patch)
tree667463aca1ed00983f419e8648ba92fc1222a832 /source/blender/blenkernel/intern/scene.c
parent8cbfc4c76ed7747111e387863ad511939d389d87 (diff)
RNA: Validate scene/view-layer combination for statistics query
Users may input an invalid scene/view-layer combination via Python. We can easily detect that and fail gracefully. Besides checking input parameters in RNA, also assert the scene/view-layer combination is valid in lower level Depsgraph lookup function (called by statistics query).
Diffstat (limited to 'source/blender/blenkernel/intern/scene.c')
-rw-r--r--source/blender/blenkernel/intern/scene.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 6f1cca619ff..1dc51c9ddae 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1129,6 +1129,17 @@ int BKE_scene_base_iter_next(
return iter->phase;
}
+Scene *BKE_scene_find_from_view_layer(const Main *bmain, const ViewLayer *layer)
+{
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (BLI_findindex(&scene->view_layers, layer) != -1) {
+ return scene;
+ }
+ }
+
+ return NULL;
+}
+
Scene *BKE_scene_find_from_collection(const Main *bmain, const Collection *collection)
{
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
@@ -2246,6 +2257,7 @@ static Depsgraph **scene_get_depsgraph_p(Main *bmain,
{
BLI_assert(scene != NULL);
BLI_assert(view_layer != NULL);
+ BLI_assert(BKE_scene_find_from_view_layer(bmain, view_layer) == scene);
/* Make sure hash itself exists. */
if (allocate_ghash_entry) {
BKE_scene_ensure_depsgraph_hash(scene);