diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-05 13:50:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-05 13:50:58 +0300 |
commit | cacd68c3359c74f5f2ab7bae304ffeb59ee6e9da (patch) | |
tree | 9b2ca3d2eea82189c8700889973f0f5dd7c59a3b | |
parent | 06d5d53a240cf98aee52a45317ac2f979be7e58a (diff) |
python console autocomplete would crash (missing NULL check for pose channels)
add rna functions id.animation_data_create() and id.animation_data_clear() - works for all ID types that support animdata.
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 130ffeb412a..b0e255d60d4 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -196,7 +196,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult bArmature *arm= (obact) ? obact->data : NULL; bPoseChannel *pchan; - if (obact && arm) { + if (obact && obact->pose && arm) { for (pchan= obact->pose->chanbase.first; pchan; pchan= pchan->next) { /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) { @@ -211,7 +211,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult bArmature *arm= (obact) ? obact->data : NULL; bPoseChannel *pchan; - if (obact && arm) { + if (obact && obact->pose && arm) { for (pchan= obact->pose->chanbase.first; pchan; pchan= pchan->next) { /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) { diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index bc5c99f0a1e..3de347cf80e 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -69,6 +69,7 @@ EnumPropertyItem id_type_items[] = { #include "BKE_idprop.h" #include "BKE_library.h" +#include "BKE_animsys.h" /* name functions that ignore the first two ID characters */ void rna_ID_name_get(PointerRNA *ptr, char *value) @@ -326,6 +327,15 @@ static void rna_def_ID(BlenderRNA *brna) RNA_def_function_ui_description(func, "Create a copy of this datablock (not supported for all datablocks)."); parm= RNA_def_pointer(func, "id", "ID", "", "New copy of the ID."); RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "animation_data_create", "BKE_id_add_animdata"); + 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_free_animdata"); + RNA_def_function_ui_description(func, "Clear animation on this this ID."); + } static void rna_def_library(BlenderRNA *brna) |