Modified AudioServer to clean up references before the singleton is removed.

This allows objects requiring the singleton for cleanup avoid a null pointer de-reference.

fixes #116298

(cherry picked from commit 9655415fc44687702dd366c02a3ae7b28f2061f2)
This commit is contained in:
Kiri Jolly
2026-02-14 17:25:26 -08:00
committed by Thaddeus Crews
parent d37348f94c
commit 2ec95001ec
2 changed files with 11 additions and 0 deletions
+9
View File
@@ -1608,6 +1608,11 @@ void AudioServer::update() {
for (CallbackItem *ci : update_callback_list) {
ci->callback(ci->userdata);
}
_cleanup_lists();
}
void AudioServer::_cleanup_lists() {
mix_callback_list.maybe_cleanup();
update_callback_list.maybe_cleanup();
listener_changed_callback_list.maybe_cleanup();
@@ -2124,6 +2129,10 @@ AudioServer::AudioServer() {
}
AudioServer::~AudioServer() {
// Cleanup resources while we still have an active AudioServer singleton,
// for resources that depend on the singleton still existing.
_cleanup_lists();
singleton = nullptr;
}
+2
View File
@@ -315,6 +315,8 @@ private:
void _delete_stream_playback(Ref<AudioStreamPlayback> p_playback);
void _delete_stream_playback_list_node(AudioStreamPlaybackListNode *p_node);
void _cleanup_lists();
// TODO document if this is necessary.
SafeList<AudioStreamPlaybackBusDetails *> bus_details_graveyard_frame_old;