Skip to content

Commit

Permalink
Merge pull request #77633 from MarioLiebisch/core-type-free-order
Browse files Browse the repository at this point in the history
Properly free core types in reverse order
  • Loading branch information
YuriSizov authored May 30, 2023
2 parents abba4e9 + f381543 commit 6101240
Showing 1 changed file with 17 additions and 14 deletions.
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

0 comments on commit 6101240

Please sign in to comment.