Skip to content

Commit 1ba920f

Browse files
authored
Merge pull request #85308 from YuriSizov/editor-fix-animation-backup-copy-crash
Fix a crash when trying to restore uncopyable animation tracks
2 parents d6a1db2 + 671c04f commit 1ba920f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scene/animation/animation_mixer.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,14 +2143,22 @@ void AnimatedValuesBackup::set_data(const HashMap<NodePath, AnimationMixer::Trac
21432143
clear_data();
21442144

21452145
for (const KeyValue<NodePath, AnimationMixer::TrackCache *> &E : p_data) {
2146-
data.insert(E.key, get_cache_copy(E.value));
2146+
AnimationMixer::TrackCache *track = get_cache_copy(E.value);
2147+
if (!track) {
2148+
continue; // Some types of tracks do not get a copy and must be ignored.
2149+
}
2150+
2151+
data.insert(E.key, track);
21472152
}
21482153
}
21492154

21502155
HashMap<NodePath, AnimationMixer::TrackCache *> AnimatedValuesBackup::get_data() const {
21512156
HashMap<NodePath, AnimationMixer::TrackCache *> ret;
21522157
for (const KeyValue<NodePath, AnimationMixer::TrackCache *> &E : data) {
2153-
ret.insert(E.key, get_cache_copy(E.value));
2158+
AnimationMixer::TrackCache *track = get_cache_copy(E.value);
2159+
ERR_CONTINUE(!track); // Backup shouldn't contain tracks that cannot be copied, this is a mistake.
2160+
2161+
ret.insert(E.key, track);
21542162
}
21552163
return ret;
21562164
}

0 commit comments

Comments
 (0)