Browse Source

Merge pull request #88446 from AThousandShips/audio_key_fix

Fix crash with animation audio track offset
Rémi Verschelde 1 year ago
parent
commit
4ce5e261b3
1 changed files with 7 additions and 1 deletions
  1. 7 1
      editor/animation_track_editor.cpp

+ 7 - 1
editor/animation_track_editor.cpp

@@ -5907,7 +5907,7 @@ void AnimationTrackEditor::_edit_menu_about_to_popup() {
 
 
 	bool has_length = false;
 	bool has_length = false;
 	for (const KeyValue<SelectedKey, KeyInfo> &E : selection) {
 	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;
 			has_length = true;
 			break;
 			break;
 		}
 		}
@@ -6247,6 +6247,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
 					continue;
 					continue;
 				}
 				}
 				Ref<AudioStream> stream = animation->audio_track_get_key_stream(E.key.track, E.key.key);
 				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);
 				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);
 				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);
 				double prev_time = animation->track_get_key_time(E.key.track, E.key.key);
@@ -6273,6 +6276,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
 					continue;
 					continue;
 				}
 				}
 				Ref<AudioStream> stream = animation->audio_track_get_key_stream(E.key.track, E.key.key);
 				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);
 				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);
 				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);
 				double prev_time = animation->track_get_key_time(E.key.track, E.key.key);