From be652f160d02c5286765905462f6332ec7cf5ca1 Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Wed, 10 Apr 2024 12:28:02 +0200 Subject: [PATCH] [Audio] Prevent crash in interactive playback --- modules/interactive_music/audio_stream_interactive.cpp | 2 ++ modules/interactive_music/register_types.cpp | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/interactive_music/audio_stream_interactive.cpp b/modules/interactive_music/audio_stream_interactive.cpp index 01764d66ed1..d7762295eb0 100644 --- a/modules/interactive_music/audio_stream_interactive.cpp +++ b/modules/interactive_music/audio_stream_interactive.cpp @@ -976,6 +976,8 @@ void AudioStreamPlaybackInteractive::switch_to_clip_by_name(const StringName &p_ return; } + ERR_FAIL_COND_MSG(stream.is_null(), "Attempted to switch while not playing back any stream."); + for (int i = 0; i < stream->get_clip_count(); i++) { if (stream->get_clip_name(i) == p_name) { switch_request = i; diff --git a/modules/interactive_music/register_types.cpp b/modules/interactive_music/register_types.cpp index 5baea13f817..6175ea6493f 100644 --- a/modules/interactive_music/register_types.cpp +++ b/modules/interactive_music/register_types.cpp @@ -42,11 +42,11 @@ void initialize_interactive_music_module(ModuleInitializationLevel p_level) { if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) { GDREGISTER_CLASS(AudioStreamPlaylist); - GDREGISTER_VIRTUAL_CLASS(AudioStreamPlaybackPlaylist); + GDREGISTER_ABSTRACT_CLASS(AudioStreamPlaybackPlaylist); GDREGISTER_CLASS(AudioStreamInteractive); - GDREGISTER_VIRTUAL_CLASS(AudioStreamPlaybackInteractive); + GDREGISTER_ABSTRACT_CLASS(AudioStreamPlaybackInteractive); GDREGISTER_CLASS(AudioStreamSynchronized); - GDREGISTER_VIRTUAL_CLASS(AudioStreamPlaybackSynchronized); + GDREGISTER_ABSTRACT_CLASS(AudioStreamPlaybackSynchronized); } #ifdef TOOLS_ENABLED if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {