Skip to content

Commit

Permalink
Merge pull request #88446 from AThousandShips/audio_key_fix
Browse files Browse the repository at this point in the history
Fix crash with animation audio track offset
  • Loading branch information
akien-mga committed Feb 17, 2024
2 parents 02f4a66 + fc3a293 commit 4ce5e26
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5907,7 +5907,7 @@ void AnimationTrackEditor::_edit_menu_about_to_popup() {

bool has_length = false;
for (const KeyValue<SelectedKey, KeyInfo> &E : selection) {
if (animation->track_get_type(E.key.track) == Animation::TYPE_AUDIO) {
if (animation->track_get_type(E.key.track) == Animation::TYPE_AUDIO && animation->audio_track_get_key_stream(E.key.track, E.key.key).is_valid()) {
has_length = true;
break;
}
Expand Down Expand Up @@ -6247,6 +6247,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
continue;
}
Ref<AudioStream> stream = animation->audio_track_get_key_stream(E.key.track, E.key.key);
if (stream.is_null()) {
continue;
}
double len = stream->get_length() - animation->audio_track_get_key_end_offset(E.key.track, E.key.key);
real_t prev_offset = animation->audio_track_get_key_start_offset(E.key.track, E.key.key);
double prev_time = animation->track_get_key_time(E.key.track, E.key.key);
Expand All @@ -6273,6 +6276,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
continue;
}
Ref<AudioStream> stream = animation->audio_track_get_key_stream(E.key.track, E.key.key);
if (stream.is_null()) {
continue;
}
double len = stream->get_length() - animation->audio_track_get_key_start_offset(E.key.track, E.key.key);
real_t prev_offset = animation->audio_track_get_key_end_offset(E.key.track, E.key.key);
double prev_time = animation->track_get_key_time(E.key.track, E.key.key);
Expand Down

0 comments on commit 4ce5e26

Please sign in to comment.