Fix: Regression of Python API for anim.keyframe_insert
Caused by #113504 The `type` property has been removed from the operator, but of course that is a breaking change in 4.1. (e.g. reported here: #117547) At the time of making the patch, I wasn't sure how to handle all cases but it turns out its not complicated. I've added back the property with the following logic. * Try to get the `KeyingSet` from the `type`. * `type` defaults to 0 which means the `ANIM_keyingset_get_from_enum_type` will get it from the scene. * If the scene doesn't have one, or a valid index isn't passed in the `KeyingSet` will be a `nullptr` in which case it inserts from the user preferences. Pull Request: https://projects.blender.org/blender/blender/pulls/117718
This commit is contained in:
committed by
Christoph Lendenfeld
parent
24bc2fef1d
commit
b2aa36485b
@@ -374,7 +374,8 @@ static int insert_key_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
/* Use the active keying set if there is one. */
|
||||
KeyingSet *ks = ANIM_keyingset_get_from_enum_type(scene, scene->active_keyingset);
|
||||
const int type = RNA_enum_get(op->ptr, "type");
|
||||
KeyingSet *ks = ANIM_keyingset_get_from_enum_type(scene, type);
|
||||
if (ks) {
|
||||
return insert_key_with_keyingset(C, op, ks);
|
||||
}
|
||||
@@ -396,6 +397,13 @@ void ANIM_OT_keyframe_insert(wmOperatorType *ot)
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* Allows passing in a keying set when using the Python operator. */
|
||||
PropertyRNA *prop = RNA_def_enum(
|
||||
ot->srna, "type", rna_enum_dummy_DEFAULT_items, 0, "Keying Set", "The Keying Set to use");
|
||||
RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf);
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
ot->prop = prop;
|
||||
}
|
||||
|
||||
static int keyframe_insert_with_keyingset_exec(bContext *C, wmOperator *op)
|
||||
|
||||
Reference in New Issue
Block a user