Fix: correctly update Actions when renaming/re-typing a custom property

Fix: correctly update Actions when renaming/re-typing a custom property

When renaming a custom property on a data-block, only update the
animation in a slot for that data-block. Previously all F-Curves were
updated, even when they were meant for other data-blocks.

This also handles the cases where the type of a custom property is
changed, and not just its name.

This is part of #146586

Pull Request: https://projects.blender.org/blender/blender/pulls/146979
This commit is contained in:
Sybren A. Stüvel
2025-09-30 10:23:20 +02:00
parent a59be80d38
commit acde9be6fd
2 changed files with 21 additions and 29 deletions

View File

@@ -27,6 +27,7 @@ from bpy.app.translations import (
pgettext_rpt as rpt_,
contexts as i18n_contexts,
)
from bpy_extras import anim_utils
def _rna_path_prop_search_for_context_impl(context, edit_text, unique_attrs):
@@ -1841,15 +1842,19 @@ class WM_OT_properties_edit(Operator):
def _update_strips(strips):
for st in strips:
if st.type == 'CLIP' and st.action:
_update(st.action.fcurves)
if st.type == 'CLIP':
channelbag = anim_utils.action_get_channelbag_for_slot(st.action, st.action_slot)
if not channelbag:
continue
_update(channelbag.fcurves)
elif st.type == 'META':
_update_strips(st.strips)
adt = getattr(item, "animation_data", None)
if adt is not None:
if adt.action:
_update(adt.action.fcurves)
channelbag = anim_utils.action_get_channelbag_for_slot(adt.action, adt.action_slot)
if channelbag:
_update(channelbag.fcurves)
if adt.drivers:
_update(adt.drivers)
if adt.nla_tracks:

View File

@@ -868,15 +868,10 @@ static bool nlastrips_path_rename_fix(ID *owner_id,
LISTBASE_FOREACH (NlaStrip *, strip, strips) {
/* fix strip's action */
if (strip->act != nullptr) {
const Vector<FCurve *> fcurves = blender::animrig::legacy::fcurves_for_action_slot(
strip->act, strip->action_slot_handle);
const bool is_changed_action = fcurves_path_rename_fix(
owner_id,
prefix,
oldName,
newName,
oldKey,
newKey,
blender::animrig::legacy::fcurves_all(strip->act),
verify_paths);
owner_id, prefix, oldName, newName, oldKey, newKey, fcurves, verify_paths);
if (is_changed_action) {
DEG_id_tag_update(&strip->act->id, ID_RECALC_ANIMATION);
}
@@ -1036,28 +1031,20 @@ void BKE_animdata_fix_paths_rename(ID *owner_id,
newN = BLI_sprintfN("[%d]", newSubscript);
}
/* Active action and temp action. */
if (adt->action != nullptr) {
if (fcurves_path_rename_fix(owner_id,
prefix,
oldName,
newName,
oldN,
newN,
blender::animrig::legacy::fcurves_all(adt->action),
verify_paths))
if (adt->action != nullptr && adt->slot_handle != blender::animrig::Slot::unassigned) {
const Vector<FCurve *> fcurves = blender::animrig::legacy::fcurves_for_action_slot(
adt->action, adt->slot_handle);
if (fcurves_path_rename_fix(
owner_id, prefix, oldName, newName, oldN, newN, fcurves, verify_paths))
{
DEG_id_tag_update(&adt->action->id, ID_RECALC_SYNC_TO_EVAL);
}
}
if (adt->tmpact) {
if (fcurves_path_rename_fix(owner_id,
prefix,
oldName,
newName,
oldN,
newN,
blender::animrig::legacy::fcurves_all(adt->tmpact),
verify_paths))
const Vector<FCurve *> fcurves = blender::animrig::legacy::fcurves_for_action_slot(
adt->tmpact, adt->tmp_slot_handle);
if (fcurves_path_rename_fix(
owner_id, prefix, oldName, newName, oldN, newN, fcurves, verify_paths))
{
DEG_id_tag_update(&adt->tmpact->id, ID_RECALC_SYNC_TO_EVAL);
}