[Bf-blender-cvs] [07f07a1] depsgraph_refactor: Depsgraph: Fixes for crash with gilgamesh file from tube

Sergey Sharybin noreply at git.blender.org
Mon Mar 2 11:18:43 CET 2015


Commit: 07f07a1bfc34168c5ad7c9b223d348f47dff3b23
Author: Sergey Sharybin
Date:   Mon Mar 2 15:14:29 2015 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rB07f07a1bfc34168c5ad7c9b223d348f47dff3b23

Depsgraph: Fixes for crash with gilgamesh file from tube

Few issues solved:

- Avoid drivers operation re-creation, it's not a total failure for
  now in case of drivers, but having assert abort for other cases is
  rather handy.

  Will check on better way to avoid drivers operations re-creation
  later this week.

- Avoid null pointer de-reference in the error prints.
  There might be still some around, but the file does no longer crash.

Didn't check the file in all the details, it's now at least opening
fine (some errors are printed to the console, will check on them later
as well).

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

M	source/blender/depsgraph/intern/depsgraph_build.cpp
M	source/blender/depsgraph/intern/depsgraph_build.h
M	source/blender/depsgraph/intern/depsgraph_build_nodes.cpp

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

diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index f250819..dc4ae34 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -291,8 +291,18 @@ bool DepsgraphNodeBuilder::has_operation_node(ID *id,
                                               eDepsOperation_Code opcode,
                                               const string &description)
 {
+	return find_operation_node(id, comp_type, comp_name, optype, opcode, description) != NULL;
+}
+
+OperationDepsNode *DepsgraphNodeBuilder::find_operation_node(ID *id,
+                                                             eDepsNode_Type comp_type,
+                                                             const string &comp_name,
+                                                             eDepsOperation_Type optype,
+                                                             eDepsOperation_Code opcode,
+                                                             const string &description)
+{
 	ComponentDepsNode *comp_node = add_component_node(id, comp_type, comp_name);
-	return comp_node->has_operation(opcode, description) != NULL;
+	return comp_node->has_operation(opcode, description);
 }
 
 /* ************************************************* */
@@ -336,7 +346,8 @@ ComponentDepsNode *DepsgraphRelationBuilder::find_node(const ComponentKey &key)
 {
 	IDDepsNode *id_node = m_graph->find_id_node(key.id);
 	if (!id_node) {
-		fprintf(stderr, "find_node component: Could not find ID %s\n", key.id->name);
+		fprintf(stderr, "find_node component: Could not find ID %s\n",
+		        (key.id != NULL) ? key.id->name : "<null>");
 		return NULL;
 	}
 
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index fe3b363..dbe2784 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -78,6 +78,22 @@ struct DepsgraphNodeBuilder {
 	bool has_operation_node(ID *id, eDepsNode_Type comp_type, const string &comp_name, eDepsOperation_Type optype,
 	                        eDepsOperation_Code opcode, const string &description = "");
 
+	OperationDepsNode *find_operation_node(ID *id,
+	                                       eDepsNode_Type comp_type,
+	                                       const string &comp_name,
+	                                       eDepsOperation_Type optype,
+	                                       eDepsOperation_Code opcode,
+	                                       const string &description = "");
+
+	OperationDepsNode *find_operation_node(ID *id,
+	                                       eDepsNode_Type comp_type,
+	                                       eDepsOperation_Type optype,
+	                                       eDepsOperation_Code opcode,
+	                                       const string &description = "")
+	{
+		return find_operation_node(id, comp_type, "", optype, opcode, description);
+	}
+
 	void build_scene(Main *bmain, Scene *scene);
 	SubgraphDepsNode *build_subgraph(Group *group);
 	void build_group(Scene *scene, Base *base, Object *object, Group *group);
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index ebd01df..a84c90d 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -416,10 +416,22 @@ OperationDepsNode *DepsgraphNodeBuilder::build_driver(ID *id, FCurve *fcu)
 {
 	ChannelDriver *driver = fcu->driver;
 
-	/* create data node for this driver ..................................... */
-	OperationDepsNode *driver_op = add_operation_node(id, DEPSNODE_TYPE_PARAMETERS,
-	                                                  DEPSOP_TYPE_EXEC, function_bind(BKE_animsys_eval_driver, _1, id, fcu),
-	                                                  DEG_OPCODE_DRIVER, deg_fcurve_id_name(fcu));
+	/* Create data node for this driver */
+	/* TODO(sergey): Avoid creating same operation multiple times,
+	 * in the future we need to avoid lookup of the operaiton as well
+	 * and use some tagging magic instead.
+	 */
+	OperationDepsNode *driver_op = find_operation_node(id,
+	                                                   DEPSNODE_TYPE_PARAMETERS,
+	                                                   DEPSOP_TYPE_EXEC,
+	                                                   DEG_OPCODE_DRIVER,
+	                                                   deg_fcurve_id_name(fcu));
+
+	if (driver_op == NULL) {
+		driver_op = add_operation_node(id, DEPSNODE_TYPE_PARAMETERS,
+		                               DEPSOP_TYPE_EXEC, function_bind(BKE_animsys_eval_driver, _1, id, fcu),
+		                               DEG_OPCODE_DRIVER, deg_fcurve_id_name(fcu));
+	}
 
 	/* tag "scripted expression" drivers as needing Python (due to GIL issues, etc.) */
 	if (driver->type == DRIVER_TYPE_PYTHON) {
@@ -538,7 +550,8 @@ void DepsgraphNodeBuilder::build_particles(Object *ob)
 		// TODO: for now, this will just be a placeholder "ubereval" node
 		add_operation_node(psys_comp,
 		                   DEPSOP_TYPE_EXEC, function_bind(BKE_particle_system_eval, _1, ob, psys),
-		                   DEG_OPCODE_PSYS_EVAL);
+		                   DEG_OPCODE_PSYS_EVAL,
+		                   psys->name);
 	}
 
 	/* pointcache */




More information about the Bf-blender-cvs mailing list