Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run cleanup code on DisplayServer init failure to prevent crash on exit. #95513

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Loading