From 509209894709b3e7c6b10a7d5eae392e06be32bd Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Thu, 11 Jan 2018 17:01:35 +0700 Subject: [PATCH] Destroy AudioServer after other non-core types are unregistered This is important for some GDNative bindings and probably for Mono. They may keep references to audio objects which are freed when they are unregistered. If AudioServer is already deleted at that point, it causes segfaults. --- main/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index 48537dc3a72..0b231b9d30a 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1845,11 +1845,6 @@ void Main::cleanup() { EditorNode::unregister_editor_types(); #endif - if (audio_server) { - audio_server->finish(); - memdelete(audio_server); - } - if (arvr_server) { // cleanup now before we pull the rug from underneath... memdelete(arvr_server); @@ -1861,6 +1856,11 @@ void Main::cleanup() { unregister_scene_types(); unregister_server_types(); + if (audio_server) { + audio_server->finish(); + memdelete(audio_server); + } + OS::get_singleton()->finalize(); finalize_physics();