Refactor: remove ReportList argument from insert_key

The insert key function in `animrig/keyframing.cc` took a `ReportList`
argument which it used to print messages in case of failures.

Instead this now returns a `CombinedKeyingResult` and the caller is
responsible for creating reports out of that.

To make that simpler the `ID` argument has been changed from a pointer to a reference.
The calling functions now make sure that it's not a `nullptr`.

This has the effect that there will be less messages printed in the Info panel when e.g. inserting keys with a keyingset.
This still doesn't make an error message pop up though.

Related to #119776

Pull Request: https://projects.blender.org/blender/blender/pulls/120784
This commit is contained in:
Christoph Lendenfeld
2024-04-23 10:10:23 +02:00
committed by Christoph Lendenfeld
parent 802a45902a
commit c30647a6fc
8 changed files with 217 additions and 170 deletions

View File

@@ -327,6 +327,7 @@ char pyrna_struct_keyframe_insert_doc[] =
" :rtype: boolean\n";
PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyObject *kw)
{
using namespace blender::animrig;
/* args, pyrna_struct_keyframe_parse handles these */
const char *path_full = nullptr;
int index = -1;
@@ -387,14 +388,14 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
if (prop) {
NlaStrip *strip = static_cast<NlaStrip *>(ptr.data);
FCurve *fcu = BKE_fcurve_find(&strip->fcurves, RNA_property_identifier(prop), index);
result = blender::animrig::insert_keyframe_direct(&reports,
ptr,
prop,
fcu,
&anim_eval_context,
eBezTriple_KeyframeType(keytype),
nullptr,
eInsertKeyFlags(options));
result = insert_keyframe_direct(&reports,
ptr,
prop,
fcu,
&anim_eval_context,
eBezTriple_KeyframeType(keytype),
nullptr,
eInsertKeyFlags(options));
}
else {
BKE_reportf(&reports, RPT_ERROR, "Could not resolve path (%s)", path_full);
@@ -404,15 +405,19 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
ID *id = self->ptr.owner_id;
BLI_assert(BKE_id_is_in_global_main(id));
result = (blender::animrig::insert_keyframe(G_MAIN,
&reports,
id,
group_name,
path_full,
index,
&anim_eval_context,
eBezTriple_KeyframeType(keytype),
eInsertKeyFlags(options)) != 0);
CombinedKeyingResult combined_result = insert_keyframe(G_MAIN,
*id,
group_name,
path_full,
index,
&anim_eval_context,
eBezTriple_KeyframeType(keytype),
eInsertKeyFlags(options));
const int success_count = combined_result.get_count(SingleKeyingResult::SUCCESS);
if (success_count == 0) {
combined_result.generate_reports(&reports);
}
result = success_count != 0;
}
MEM_freeN((void *)path_full);