From e516479889dca4ad2a7faca4e16389b6d50bb44d Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Fri, 17 May 2024 21:29:11 +0200 Subject: [PATCH] Release Engine after unregistering GDExtensions The Engine is used to retrieve singletons, and GDExtensions may try to retrieve a singleton (e.g.: `OS`) in their deinitialization. --- main/main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index 66706be7458..b755cc9124e 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -4295,9 +4295,6 @@ void Main::cleanup(bool p_force) { if (globals) { memdelete(globals); } - if (engine) { - memdelete(engine); - } if (OS::get_singleton()->is_restart_on_exit_set()) { //attempt to restart with arguments @@ -4315,6 +4312,10 @@ void Main::cleanup(bool p_force) { uninitialize_modules(MODULE_INITIALIZATION_LEVEL_CORE); unregister_core_types(); + if (engine) { + memdelete(engine); + } + OS::get_singleton()->benchmark_end_measure("Shutdown", "Total"); OS::get_singleton()->benchmark_dump();