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

Properly free core types in reverse order #77633

Merged
merged 1 commit into from
May 30, 2023
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
31 changes: 17 additions & 14 deletions core/register_core_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,21 +365,28 @@ void unregister_core_extensions() {
void unregister_core_types() {
OS::get_singleton()->benchmark_begin_measure("unregister_core_types");

memdelete(gdextension_manager);
// Destroy singletons in reverse order to ensure dependencies are not broken.

memdelete(worker_thread_pool);

memdelete(resource_uid);
memdelete(_resource_loader);
memdelete(_resource_saver);
memdelete(_os);
memdelete(_engine);
memdelete(_classdb);
memdelete(_marshalls);
memdelete(_engine_debugger);
memdelete(_marshalls);
memdelete(_classdb);
memdelete(_engine);
memdelete(_os);
memdelete(_resource_saver);
memdelete(_resource_loader);

memdelete(_geometry_2d);
memdelete(_geometry_3d);
memdelete(_geometry_2d);

memdelete(worker_thread_pool);
memdelete(gdextension_manager);

memdelete(resource_uid);

if (ip) {
memdelete(ip);
}

ResourceLoader::remove_resource_format_loader(resource_format_image);
resource_format_image.unref();
Expand Down Expand Up @@ -410,10 +417,6 @@ void unregister_core_types() {
ResourceLoader::remove_resource_format_loader(resource_loader_json);
resource_loader_json.unref();

if (ip) {
memdelete(ip);
}

ResourceLoader::remove_resource_format_loader(resource_loader_gdextension);
resource_loader_gdextension.unref();

Expand Down