From 671c04f89f449f94e9d129d2fa0b96d3f65dd191 Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Fri, 24 Nov 2023 14:16:02 +0100 Subject: [PATCH] Fix a crash when trying to restore uncopyable animation tracks --- scene/animation/animation_mixer.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scene/animation/animation_mixer.cpp b/scene/animation/animation_mixer.cpp index f375b2eb83c..dbd790003a8 100644 --- a/scene/animation/animation_mixer.cpp +++ b/scene/animation/animation_mixer.cpp @@ -2143,14 +2143,22 @@ void AnimatedValuesBackup::set_data(const HashMap &E : p_data) { - data.insert(E.key, get_cache_copy(E.value)); + AnimationMixer::TrackCache *track = get_cache_copy(E.value); + if (!track) { + continue; // Some types of tracks do not get a copy and must be ignored. + } + + data.insert(E.key, track); } } HashMap AnimatedValuesBackup::get_data() const { HashMap ret; for (const KeyValue &E : data) { - ret.insert(E.key, get_cache_copy(E.value)); + AnimationMixer::TrackCache *track = get_cache_copy(E.value); + ERR_CONTINUE(!track); // Backup shouldn't contain tracks that cannot be copied, this is a mistake. + + ret.insert(E.key, track); } return ret; }