Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2020-01-23 16:43:51 +0300
committermano-wii <germano.costa@ig.com.br>2020-01-23 16:44:19 +0300
commit24ebed4d841ea9828a869d917a5718c829f09430 (patch)
tree3ec1f221743e41592a89241fc833f34ecb0536f3 /source/blender/editors/space_action
parent79122aec307c8521ce21b9ef253527fe67d946fc (diff)
Fix T51011: bpy.ops.action.new does nothing when invoked from script
The operator always expect to be called form a button. But this is not always the case. This does not bring functional changes when not called from python.
Diffstat (limited to 'source/blender/editors/space_action')
-rw-r--r--source/blender/editors/space_action/action_data.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c
index 5ceaefd6309..5fdabea62c1 100644
--- a/source/blender/editors/space_action/action_data.c
+++ b/source/blender/editors/space_action/action_data.c
@@ -211,12 +211,13 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
PointerRNA ptr, idptr;
PropertyRNA *prop;
+ bAction *oldact = NULL;
+ AnimData *adt = NULL;
/* hook into UI */
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
if (prop) {
- bAction *action = NULL, *oldact = NULL;
- AnimData *adt = NULL;
+ /* The operator was called from a button. */
PointerRNA oldptr;
oldptr = RNA_property_pointer_get(&ptr, prop);
@@ -229,6 +230,13 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
else if (ptr.type == &RNA_SpaceDopeSheetEditor) {
adt = ED_actedit_animdata_from_context(C);
}
+ }
+ else {
+ adt = ED_actedit_animdata_from_context(C);
+ oldact = adt->action;
+ }
+ {
+ bAction *action = NULL;
/* Perform stashing operation - But only if there is an action */
if (adt && oldact) {
@@ -257,12 +265,14 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
/* create action */
action = action_create_new(C, oldact);
- /* set this new action
- * NOTE: we can't use actedit_change_action, as this function is also called from the NLA
- */
- RNA_id_pointer_create(&action->id, &idptr);
- RNA_property_pointer_set(&ptr, prop, idptr, NULL);
- RNA_property_update(C, &ptr, prop);
+ if (prop) {
+ /* set this new action
+ * NOTE: we can't use actedit_change_action, as this function is also called from the NLA
+ */
+ RNA_id_pointer_create(&action->id, &idptr);
+ RNA_property_pointer_set(&ptr, prop, idptr, NULL);
+ RNA_property_update(C, &ptr, prop);
+ }
}
/* set notifier that keyframes have changed */