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:
committed by
Thaddeus Crews
parent
d37348f94c
commit
2ec95001ec
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user