diff --git a/main/main.cpp b/main/main.cpp index 1cdfad78368..44201522af1 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -838,13 +838,15 @@ void Main::test_cleanup() { if (globals) { memdelete(globals); } - if (engine) { - memdelete(engine); - } unregister_core_driver_types(); unregister_core_extensions(); uninitialize_modules(MODULE_INITIALIZATION_LEVEL_CORE); + + if (engine) { + memdelete(engine); + } + unregister_core_types(); OS::get_singleton()->finalize_core(); @@ -2496,15 +2498,17 @@ error: if (globals) { memdelete(globals); } - if (engine) { - memdelete(engine); - } if (packed_data) { memdelete(packed_data); } unregister_core_driver_types(); unregister_core_extensions(); + + if (engine) { + memdelete(engine); + } + unregister_core_types(); OS::get_singleton()->_cmdline.clear(); @@ -4365,12 +4369,13 @@ void Main::cleanup(bool p_force) { unregister_core_driver_types(); unregister_core_extensions(); uninitialize_modules(MODULE_INITIALIZATION_LEVEL_CORE); - unregister_core_types(); if (engine) { memdelete(engine); } + unregister_core_types(); + OS::get_singleton()->benchmark_end_measure("Shutdown", "Total"); OS::get_singleton()->benchmark_dump();