Anim: always allow unassigning the action slot

Setting `id.animation_data.action_slot = None` should always be
possible, even when there is no Action assigned (that is, when
`id.animation_data.action = None`). In that case `.action_slot` should
already be `None`, and so writing its current value should not cause any
errors.

Pull Request: https://projects.blender.org/blender/blender/pulls/126827
This commit is contained in:
Sybren A. Stüvel
2024-08-27 14:53:55 +02:00
parent 51f7936335
commit f018c4a989

View File

@@ -312,21 +312,23 @@ static void rna_AnimData_action_slot_set(PointerRNA *ptr, PointerRNA value, Repo
using animrig::Action;
using animrig::Slot;
AnimData &adt = rna_animdata(ptr);
if (!adt.action) {
BKE_report(reports, RPT_ERROR, "Cannot set slot without an assigned Action.");
return;
}
ID *animated_id = ptr->owner_id;
BLI_assert(animated_id); /* Otherwise there is nothing to own this AnimData. */
/* A 'None' value for the slot is always valid, regardless of whether an
* Action was assigned or not. */
ActionSlot *dna_slot = static_cast<ActionSlot *>(value.data);
if (!dna_slot) {
animrig::unassign_slot(*animated_id);
return;
}
AnimData &adt = rna_animdata(ptr);
if (!adt.action) {
BKE_report(reports, RPT_ERROR, "Cannot set slot without an assigned Action.");
return;
}
Action &action = adt.action->wrap();
Slot &slot = dna_slot->wrap();