Depsgraph: fix some DEG queries crashing with new, empty graph.

Calling code is responsible to check on NULL pointers here, or ensure
is does have a fully built and evaluated depsgraph, but this should
never crash in DEG queries themselves.
This commit is contained in:
Bastien Montagne 2018-08-02 17:15:56 +02:00
parent 771973869d
commit 9914c05bd7
1 changed files with 5 additions and 2 deletions

View File

@ -128,10 +128,10 @@ Scene *DEG_get_evaluated_scene(const Depsgraph *graph)
reinterpret_cast<const DEG::Depsgraph *>(graph);
Scene *scene_cow = deg_graph->scene_cow;
/* TODO(sergey): Shall we expand datablock here? Or is it OK to assume
* that calleer is OK with just a pointer in case scene is not up[dated
* that calleer is OK with just a pointer in case scene is not updated
* yet?
*/
BLI_assert(DEG::deg_copy_on_write_is_expanded(&scene_cow->id));
BLI_assert(scene_cow != NULL && DEG::deg_copy_on_write_is_expanded(&scene_cow->id));
return scene_cow;
}
@ -140,6 +140,9 @@ ViewLayer *DEG_get_evaluated_view_layer(const Depsgraph *graph)
const DEG::Depsgraph *deg_graph =
reinterpret_cast<const DEG::Depsgraph *>(graph);
Scene *scene_cow = DEG_get_evaluated_scene(graph);
if (scene_cow == NULL) {
return NULL; /* Happens with new, not-yet-built/evaluated graphes. */
}
/* Do name-based lookup. */
/* TODO(sergey): Can this be optimized? */
ViewLayer *view_layer_orig = deg_graph->view_layer;