Anim: Multi Editing for FCurve modifiers #112419

Merged
Christoph Lendenfeld merged 2 commits from ChrisLend/blender:fcu_mod_multi_edit into main 2023-09-21 09:57:25 +02:00
1 changed files with 6 additions and 12 deletions
Showing only changes of commit dd92d03c61 - Show all commits

View File

@ -1057,13 +1057,12 @@ static void ui_context_selected_bones_via_pose(bContext *C, ListBase *r_lb)
static void ui_context_fcurve_modifiers_via_fcurve(bContext *C, ListBase *r_lb, FModifier *source)
{
ListBase lb;
lb = CTX_data_collection_get(C, "selected_editable_fcurves");
if (BLI_listbase_is_empty(&lb)) {
ListBase /* CollectionPointerLink */ fcurve_links;

As a rule of thumb, I always recommend documenting what's in the listbase, so ListBase /*CollectionPointerLink*/ lb.

And probably a better name than lb is also more 'modern', so something like ListBase /*CollectionPointerLink*/ fcurve_links?

As a rule of thumb, I always recommend documenting what's in the listbase, so `ListBase /*CollectionPointerLink*/ lb`. And probably a better name than `lb` is also more 'modern', so something like `ListBase /*CollectionPointerLink*/ fcurve_links`?
fcurve_links = CTX_data_collection_get(C, "selected_editable_fcurves");
if (BLI_listbase_is_empty(&fcurve_links)) {
return;
}
blender::Vector<CollectionPointerLink *> pointers_to_free;
LISTBASE_FOREACH (CollectionPointerLink *, link, &lb) {
LISTBASE_FOREACH_MUTABLE (CollectionPointerLink *, link, &fcurve_links) {
FCurve *fcu = static_cast<FCurve *>(link->ptr.data);

Use LISTBASE_FOREACH_MUTABLE here, as you're modifying lb while iterating.

Use `LISTBASE_FOREACH_MUTABLE` here, as you're modifying `lb` while iterating.
bool found_modifier = false;
LISTBASE_FOREACH (FModifier *, mod, &fcu->modifiers) {
@ -1076,16 +1075,11 @@ static void ui_context_fcurve_modifiers_via_fcurve(bContext *C, ListBase *r_lb,
}
if (!found_modifier) {
/* FCurves that don't have a modifier named the same must be removed to avoid segfaults. */
BLI_remlink(&lb, link);
pointers_to_free.append(link);
BLI_freelinkN(&fcurve_links, link);
}
}
for (CollectionPointerLink *link : pointers_to_free) {
MEM_freeN(link);
}
*r_lb = lb;
*r_lb = fcurve_links;
}
bool UI_context_copy_to_selected_list(bContext *C,