forked from bartvdbraak/blender
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.
This commit is contained in:
parent
9c80e52a89
commit
82740cd282
@ -250,8 +250,8 @@ void IDDepsNode::tag_update(Depsgraph *graph)
|
|||||||
bool do_component_tag = comp_node->type != DEPSNODE_TYPE_ANIMATION;
|
bool do_component_tag = comp_node->type != DEPSNODE_TYPE_ANIMATION;
|
||||||
if (comp_node->type == DEPSNODE_TYPE_ANIMATION) {
|
if (comp_node->type == DEPSNODE_TYPE_ANIMATION) {
|
||||||
AnimData *adt = BKE_animdata_from_id(id);
|
AnimData *adt = BKE_animdata_from_id(id);
|
||||||
BLI_assert(adt != NULL);
|
/* Animation data might be null if relations are tagged for update. */
|
||||||
if (adt->recalc & ADT_RECALC_ANIM) {
|
if (adt != NULL && (adt->recalc & ADT_RECALC_ANIM)) {
|
||||||
do_component_tag = true;
|
do_component_tag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,8 @@ EnumPropertyItem id_type_items[] = {
|
|||||||
|
|
||||||
#ifdef RNA_RUNTIME
|
#ifdef RNA_RUNTIME
|
||||||
|
|
||||||
|
#include "DNA_anim_types.h"
|
||||||
|
|
||||||
#include "BKE_font.h"
|
#include "BKE_font.h"
|
||||||
#include "BKE_idprop.h"
|
#include "BKE_idprop.h"
|
||||||
#include "BKE_library.h"
|
#include "BKE_library.h"
|
||||||
@ -331,6 +333,19 @@ static void rna_ID_user_clear(ID *id)
|
|||||||
id->flag &= ~LIB_FAKEUSER;
|
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)
|
static void rna_IDPArray_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||||
{
|
{
|
||||||
IDProperty *prop = (IDProperty *)ptr->data;
|
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, "
|
RNA_def_function_ui_description(func, "Clear the user count of a datablock so its not saved, "
|
||||||
"on reload the data will be removed");
|
"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");
|
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");
|
parm = RNA_def_pointer(func, "anim_data", "AnimData", "", "New animation data or NULL");
|
||||||
RNA_def_function_return(func, parm);
|
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");
|
RNA_def_function_ui_description(func, "Clear animation on this this ID");
|
||||||
|
|
||||||
func = RNA_def_function(srna, "update_tag", "rna_ID_update_tag");
|
func = RNA_def_function(srna, "update_tag", "rna_ID_update_tag");
|
||||||
|
Loading…
Reference in New Issue
Block a user