diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2024-08-14 11:36:29 +0300 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-16 16:37:54 +0200 |
commit | 8c5edcb03af76ec93e61c253ca54973702753156 (patch) | |
tree | c6525e747486dc5c5e06fc6e5ea55443777c5a83 /main | |
parent | 79848620ce0850c9311fffbc8ea27729a5348292 (diff) | |
download | redot-engine-8c5edcb03af76ec93e61c253ca54973702753156.tar.gz |
Run cleanup code on DisplayServer init failure to prevent crash on exit.
(cherry picked from commit f15ad7235548130be49e00b44b33e8eb64bb6bc3)
Diffstat (limited to 'main')
-rw-r--r-- | main/main.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/main/main.cpp b/main/main.cpp index e42469b51b..588b8da9bd 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2465,7 +2465,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->benchmark_end_measure("Startup", "Main::Setup"); if (p_second_phase) { - return setup2(); + exit_err = setup2(); + if (exit_err != OK) { + goto error; + } } return OK; @@ -2763,6 +2766,30 @@ Error Main::setup2(bool p_show_boot_logo) { if (err != OK || display_server == nullptr) { ERR_PRINT("Unable to create DisplayServer, all display drivers failed.\nUse \"--headless\" command line argument to run the engine in headless mode if this is desired (e.g. for continuous integration)."); + + if (display_server) { + memdelete(display_server); + } + + GDExtensionManager::get_singleton()->deinitialize_extensions(GDExtension::INITIALIZATION_LEVEL_SERVERS); + uninitialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS); + unregister_server_types(); + + if (input) { + memdelete(input); + } + if (tsman) { + memdelete(tsman); + } +#ifndef _3D_DISABLED + if (physics_server_3d_manager) { + memdelete(physics_server_3d_manager); + } +#endif // _3D_DISABLED + if (physics_server_2d_manager) { + memdelete(physics_server_2d_manager); + } + return err; } |