[Bf-blender-cvs] [82740cd] master: Fix T45423: depsgraph: crash in IDDepsNode::tag_update

Sergey Sharybin noreply at git.blender.org
Tue Jul 14 11:24:29 CEST 2015


Commit: 82740cd282636fe318c3e4c7c3b1c2033857350d
Author: Sergey Sharybin
Date:   Tue Jul 14 11:19:27 2015 +0200
Branches: master
https://developer.blender.org/rB82740cd282636fe318c3e4c7c3b1c2033857350d

Fix T45423: depsgraph: crash in IDDepsNode::tag_update

Two issues fixed in this commit:

- Clearing or adding animation via python should ensure relations are valid.
- Animation component animation data might be null caused by removing animation
  from python.

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

M	source/blender/depsgraph/intern/depsnode.cc
M	source/blender/makesrna/intern/rna_ID.c

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

diff --git a/source/blender/depsgraph/intern/depsnode.cc b/source/blender/depsgraph/intern/depsnode.cc
index 1736aad..7d4d689 100644
--- a/source/blender/depsgraph/intern/depsnode.cc
+++ b/source/blender/depsgraph/intern/depsnode.cc
@@ -250,8 +250,8 @@ void IDDepsNode::tag_update(Depsgraph *graph)
 		bool do_component_tag = comp_node->type != DEPSNODE_TYPE_ANIMATION;
 		if (comp_node->type == DEPSNODE_TYPE_ANIMATION) {
 			AnimData *adt = BKE_animdata_from_id(id);
-			BLI_assert(adt != NULL);
-			if (adt->recalc & ADT_RECALC_ANIM) {
+			/* Animation data might be null if relations are tagged for update. */
+			if (adt != NULL && (adt->recalc & ADT_RECALC_ANIM)) {
 				do_component_tag = true;
 			}
 		}
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index b87b455..f3bd5fc 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -85,6 +85,8 @@ EnumPropertyItem id_type_items[] = {
 
 #ifdef RNA_RUNTIME
 
+#include "DNA_anim_types.h"
+
 #include "BKE_font.h"
 #include "BKE_idprop.h"
 #include "BKE_library.h"
@@ -331,6 +333,19 @@ static void rna_ID_user_clear(ID *id)
 	id->flag &= ~LIB_FAKEUSER;
 }
 
+static AnimData * rna_ID_animation_data_create(ID *id, Main *bmain)
+{
+	AnimData *adt = BKE_animdata_add_id(id);
+	DAG_relations_tag_update(bmain);
+	return adt;
+}
+
+static void rna_ID_animation_data_free(ID *id, Main *bmain)
+{
+	BKE_animdata_free(id);
+	DAG_relations_tag_update(bmain);
+}
+
 static void rna_IDPArray_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
 	IDProperty *prop = (IDProperty *)ptr->data;
@@ -835,12 +850,14 @@ static void rna_def_ID(BlenderRNA *brna)
 	RNA_def_function_ui_description(func, "Clear the user count of a datablock so its not saved, "
 	                                "on reload the data will be removed");
 
-	func = RNA_def_function(srna, "animation_data_create", "BKE_animdata_add_id");
+	func = RNA_def_function(srna, "animation_data_create", "rna_ID_animation_data_create");
+	RNA_def_function_flag(func, FUNC_USE_MAIN);
 	RNA_def_function_ui_description(func, "Create animation data to this ID, note that not all ID types support this");
 	parm = RNA_def_pointer(func, "anim_data", "AnimData", "", "New animation data or NULL");
 	RNA_def_function_return(func, parm);
 
-	func = RNA_def_function(srna, "animation_data_clear", "BKE_animdata_free");
+	func = RNA_def_function(srna, "animation_data_clear", "rna_ID_animation_data_free");
+	RNA_def_function_flag(func, FUNC_USE_MAIN);
 	RNA_def_function_ui_description(func, "Clear animation on this this ID");
 
 	func = RNA_def_function(srna, "update_tag", "rna_ID_update_tag");




More information about the Bf-blender-cvs mailing list