From 301b2ae183cf156cc2a89a5602642ee7828691a7 Mon Sep 17 00:00:00 2001 From: Pratik Borhade Date: Tue, 15 Oct 2024 15:16:03 +0200 Subject: [PATCH] Fix #128831: GPv3: Crash when adding action track When grease pencil has no actions (ale->adt), id data block channel is still added due to `ANIMFILTER_ANIMDATA`. This would lead to crash if operator is accessing the AnimData (ale->adt). To fix this, make sure adt exists before creating an animchannel. Pull Request: https://projects.blender.org/blender/blender/pulls/128841 --- source/blender/editors/animation/anim_filter.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/animation/anim_filter.cc b/source/blender/editors/animation/anim_filter.cc index 4b8fd038f3b..d09b331591b 100644 --- a/source/blender/editors/animation/anim_filter.cc +++ b/source/blender/editors/animation/anim_filter.cc @@ -2212,8 +2212,10 @@ static size_t animdata_filter_grease_pencil_data(bAnimContext *ac, */ if (filter_mode & ANIMFILTER_ANIMDATA) { /* Just add data block container. */ - ANIMCHANNEL_NEW_CHANNEL( - ac->bmain, grease_pencil, ANIMTYPE_GREASE_PENCIL_DATABLOCK, grease_pencil, nullptr); + if (grease_pencil->adt != nullptr) { + ANIMCHANNEL_NEW_CHANNEL( + ac->bmain, grease_pencil, ANIMTYPE_GREASE_PENCIL_DATABLOCK, grease_pencil, nullptr); + } } else { ListBase tmp_data = {nullptr, nullptr};