Skip to content

Commit 9655415

Browse files
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
1 parent bf95b62 commit 9655415

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

servers/audio/audio_server.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,11 @@ void AudioServer::update() {
16081608
for (CallbackItem *ci : update_callback_list) {
16091609
ci->callback(ci->userdata);
16101610
}
1611+
1612+
_cleanup_lists();
1613+
}
1614+
1615+
void AudioServer::_cleanup_lists() {
16111616
mix_callback_list.maybe_cleanup();
16121617
update_callback_list.maybe_cleanup();
16131618
listener_changed_callback_list.maybe_cleanup();
@@ -2124,6 +2129,10 @@ AudioServer::AudioServer() {
21242129
}
21252130

21262131
AudioServer::~AudioServer() {
2132+
// Cleanup resources while we still have an active AudioServer singleton,
2133+
// for resources that depend on the singleton still existing.
2134+
_cleanup_lists();
2135+
21272136
singleton = nullptr;
21282137
}
21292138

servers/audio/audio_server.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ class AudioServer : public Object {
315315
void _delete_stream_playback(Ref<AudioStreamPlayback> p_playback);
316316
void _delete_stream_playback_list_node(AudioStreamPlaybackListNode *p_node);
317317

318+
void _cleanup_lists();
319+
318320
// TODO document if this is necessary.
319321
SafeList<AudioStreamPlaybackBusDetails *> bus_details_graveyard_frame_old;
320322

0 commit comments

Comments
 (0)