diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-07-14 12:19:27 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-07-14 12:21:04 +0300 |
commit | 82740cd282636fe318c3e4c7c3b1c2033857350d (patch) | |
tree | 6e904ad999a48b4ab3c1428641a482d7955cce57 /source/blender | |
parent | 9c80e52a89ca1d514c57700e4916ee890c53c4c7 (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/depsgraph/intern/depsnode.cc | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 21 |
2 files changed, 21 insertions, 4 deletions
diff --git a/source/blender/depsgraph/intern/depsnode.cc b/source/blender/depsgraph/intern/depsnode.cc index 1736aadf999..7d4d6890c83 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 b87b455b36f..f3bd5fc5cef 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"); |