diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-10-29 07:53:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-29 07:53:59 +0200 |
commit | ddecaf5451890fc7d2a931807c78fd1fe3a3e65e (patch) | |
tree | 0f379ec5b81d5ea9d812df221e10a37d9546852d /scene/audio/audio_stream_player.cpp | |
parent | 93078089878296cca7548692fd2e472898379d1c (diff) | |
parent | c088a2dd897de6c20ac8f5563700f3e455aa818b (diff) |
Merge pull request #54366 from lyuma/audio_stream_player_finished_signal
Fix crash due to reentrancy in AudioStreamPlayer* finished signal.
Diffstat (limited to 'scene/audio/audio_stream_player.cpp')
-rw-r--r-- | scene/audio/audio_stream_player.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index 5065f21604..43c4ce4c82 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -45,7 +45,6 @@ void AudioStreamPlayer::_notification(int p_what) { Vector<Ref<AudioStreamPlayback>> playbacks_to_remove; for (Ref<AudioStreamPlayback> &playback : stream_playbacks) { if (playback.is_valid() && !AudioServer::get_singleton()->is_playback_active(playback) && !AudioServer::get_singleton()->is_playback_paused(playback)) { - emit_signal(SNAME("finished")); playbacks_to_remove.push_back(playback); } } @@ -58,6 +57,9 @@ void AudioStreamPlayer::_notification(int p_what) { active.clear(); set_process_internal(false); } + if (!playbacks_to_remove.is_empty()) { + emit_signal(SNAME("finished")); + } } if (p_what == NOTIFICATION_EXIT_TREE) { |