Fix: crash when loading layered animation with channel groups
The issue was that the forward compatibility saving code was setting the group's `channels` listbase to point at the forward-compatible fcurve listbase, but the `channels` listbase wasn't later getting cleared when loading the groups as part of a layered action. In fact, the listbase pointers were being completely ignored in that case because they aren't relevant to groups on layered actions, and therefore weren't getting remapped to the new correct memory addresses of the fcurves. The end result was that after loading, the group's `channels` listbase would be non-null and pointing to invalid memory, and there are some code paths that then try to use that listbase, resulting in a segfault. This commit fixes the issue by ensuring that the groups' `channels` listbases are cleared when loading them as part of a layered action. Additionally, we now also clear them after they're set during forward-compatibly saving, the lack of which wasn't immediately causing problems but was nevertheless incorrect. Pull Request: https://projects.blender.org/blender/blender/pulls/126834
This commit is contained in:
committed by
Nathan Vegdahl
parent
6b281264b2
commit
e3311e48c0
@@ -413,6 +413,7 @@ static void action_blend_write_clear_legacy_channel_groups_listbase(ListBase &li
|
||||
LISTBASE_FOREACH (bActionGroup *, group, &listbase) {
|
||||
group->prev = nullptr;
|
||||
group->next = nullptr;
|
||||
group->channels = {nullptr, nullptr};
|
||||
}
|
||||
|
||||
BLI_listbase_clear(&listbase);
|
||||
@@ -563,6 +564,11 @@ static void read_channelbag(BlendDataReader *reader, animrig::ChannelBag &channe
|
||||
for (int i = 0; i < channelbag.group_array_num; i++) {
|
||||
BLO_read_struct(reader, bActionGroup, &channelbag.group_array[i]);
|
||||
read_channel_group(reader, *channelbag.group_array[i]);
|
||||
|
||||
/* Clear the legacy channels listbase, since it will have been set for some
|
||||
* groups for forward comptability. See
|
||||
* `action_blend_write_make_legacy_channel_groups_listbase()`. */
|
||||
channelbag.group_array[i]->channels = {nullptr, nullptr};
|
||||
}
|
||||
|
||||
BLO_read_pointer_array(
|
||||
|
||||
Reference in New Issue
Block a user