Fix T98686: Cant rename local NLA tracks within a local library override data-block.

We need a specific exception to general rule 'no rename of anim channels
in liboverride data' for the locally-inserted NLA tracks.
This commit is contained in:
Bastien Montagne 2022-06-09 09:50:27 +02:00
parent 62dece5c86
commit a91c8d8efa
Notes: blender-bot 2023-07-10 15:38:12 +02:00
Referenced by issue #98712, Lots of animation-related operators do not check if the data is editable or not
Referenced by issue #98686, Cant rename local NLA tracks within a local library override data-block.
1 changed files with 26 additions and 4 deletions

View File

@ -2791,13 +2791,35 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index)
return false;
}
/* don't allow renaming linked channels */
if ((ale->fcurve_owner_id != NULL &&
(ID_IS_LINKED(ale->fcurve_owner_id) || ID_IS_OVERRIDE_LIBRARY(ale->fcurve_owner_id))) ||
(ale->id != NULL && (ID_IS_LINKED(ale->id) || ID_IS_OVERRIDE_LIBRARY(ale->id)))) {
/* Don't allow renaming linked/liboverride channels. */
if (ale->fcurve_owner_id != NULL &&
(ID_IS_LINKED(ale->fcurve_owner_id) || ID_IS_OVERRIDE_LIBRARY(ale->fcurve_owner_id))) {
ANIM_animdata_freelist(&anim_data);
return false;
}
if (ale->id != NULL) {
if (ID_IS_LINKED(ale->id)) {
ANIM_animdata_freelist(&anim_data);
return false;
}
/* There is one exception to not allowing renaming on liboverride channels: locally-inserted
* NLA tracks. */
if (ID_IS_OVERRIDE_LIBRARY(ale->id)) {
switch (ale->type) {
case ANIMTYPE_NLATRACK: {
NlaTrack *nlt = (NlaTrack *)ale->data;
if ((nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0) {
ANIM_animdata_freelist(&anim_data);
return false;
}
break;
}
default:
ANIM_animdata_freelist(&anim_data);
return false;
}
}
}
/* check that channel can be renamed */
acf = ANIM_channel_get_typeinfo(ale);