[Bf-blender-cvs] [9914c05bd76] blender2.8: Depsgraph: fix some DEG queries crashing with new, empty graph.

Bastien Montagne noreply at git.blender.org
Thu Aug 2 17:17:36 CEST 2018


Commit: 9914c05bd762d495fe3778c417ba1c7c9d7f1332
Author: Bastien Montagne
Date:   Thu Aug 2 17:15:56 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB9914c05bd762d495fe3778c417ba1c7c9d7f1332

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.

===================================================================

M	source/blender/depsgraph/intern/depsgraph_query.cc

===================================================================

diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index ca9f32d4d8c..a6c930196ef 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -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;



More information about the Bf-blender-cvs mailing list