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.
This commit is contained in:
@@ -211,12 +211,13 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
PointerRNA ptr, idptr;
|
PointerRNA ptr, idptr;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
|
||||||
|
bAction *oldact = NULL;
|
||||||
|
AnimData *adt = NULL;
|
||||||
/* hook into UI */
|
/* hook into UI */
|
||||||
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
|
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
|
||||||
|
|
||||||
if (prop) {
|
if (prop) {
|
||||||
bAction *action = NULL, *oldact = NULL;
|
/* The operator was called from a button. */
|
||||||
AnimData *adt = NULL;
|
|
||||||
PointerRNA oldptr;
|
PointerRNA oldptr;
|
||||||
|
|
||||||
oldptr = RNA_property_pointer_get(&ptr, prop);
|
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) {
|
else if (ptr.type == &RNA_SpaceDopeSheetEditor) {
|
||||||
adt = ED_actedit_animdata_from_context(C);
|
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 */
|
/* Perform stashing operation - But only if there is an action */
|
||||||
if (adt && oldact) {
|
if (adt && oldact) {
|
||||||
@@ -257,12 +265,14 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
/* create action */
|
/* create action */
|
||||||
action = action_create_new(C, oldact);
|
action = action_create_new(C, oldact);
|
||||||
|
|
||||||
/* set this new action
|
if (prop) {
|
||||||
* NOTE: we can't use actedit_change_action, as this function is also called from the NLA
|
/* 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_id_pointer_create(&action->id, &idptr);
|
||||||
RNA_property_update(C, &ptr, prop);
|
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
|
||||||
|
RNA_property_update(C, &ptr, prop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set notifier that keyframes have changed */
|
/* set notifier that keyframes have changed */
|
||||||
|
Reference in New Issue
Block a user