Properly free core types in reverse order

This fixes #62152.
This commit is contained in:
Mario Liebisch 2023-05-30 00:07:47 +02:00
parent abba4e951a
commit f381543185
No known key found for this signature in database
GPG Key ID: 32B56AC1F87EFBF9
1 changed files with 18 additions and 15 deletions

View File

@ -365,21 +365,28 @@ void unregister_core_extensions() {
void unregister_core_types() { void unregister_core_types() {
OS::get_singleton()->benchmark_begin_measure("unregister_core_types"); OS::get_singleton()->benchmark_begin_measure("unregister_core_types");
// Destroy singletons in reverse order to ensure dependencies are not broken.
memdelete(worker_thread_pool);
memdelete(_engine_debugger);
memdelete(_marshalls);
memdelete(_classdb);
memdelete(_engine);
memdelete(_os);
memdelete(_resource_saver);
memdelete(_resource_loader);
memdelete(_geometry_3d);
memdelete(_geometry_2d);
memdelete(gdextension_manager); memdelete(gdextension_manager);
memdelete(resource_uid); memdelete(resource_uid);
memdelete(_resource_loader);
memdelete(_resource_saver);
memdelete(_os);
memdelete(_engine);
memdelete(_classdb);
memdelete(_marshalls);
memdelete(_engine_debugger);
memdelete(_geometry_2d); if (ip) {
memdelete(_geometry_3d); memdelete(ip);
}
memdelete(worker_thread_pool);
ResourceLoader::remove_resource_format_loader(resource_format_image); ResourceLoader::remove_resource_format_loader(resource_format_image);
resource_format_image.unref(); resource_format_image.unref();
@ -410,10 +417,6 @@ void unregister_core_types() {
ResourceLoader::remove_resource_format_loader(resource_loader_json); ResourceLoader::remove_resource_format_loader(resource_loader_json);
resource_loader_json.unref(); resource_loader_json.unref();
if (ip) {
memdelete(ip);
}
ResourceLoader::remove_resource_format_loader(resource_loader_gdextension); ResourceLoader::remove_resource_format_loader(resource_loader_gdextension);
resource_loader_gdextension.unref(); resource_loader_gdextension.unref();