Auto-release static GDTypes at exit.

This fixes "unclaimed StringName" warnings and improves engine shutdown correctness.
This commit is contained in:
Lukas Tenbrink 2026-01-09 13:46:28 +01:00
parent 64bc9a25a3
commit 17ef5afa6c
3 changed files with 17 additions and 1 deletions

View file

@ -2420,6 +2420,7 @@ void ClassDB::cleanup_defaults() {
default_values_cached.clear();
}
LocalVector<GDType **> ClassDB::gdtype_autorelease_pool;
void ClassDB::cleanup() {
//OBJTYPE_LOCK; hah not here
@ -2440,6 +2441,15 @@ void ClassDB::cleanup() {
resource_base_extensions.clear();
compat_classes.clear();
native_structs.clear();
for (GDType **type : gdtype_autorelease_pool) {
if (!type) {
WARN_PRINT("GDType in autorelease pool was cleaned up before being auto-released. Ignoring.");
}
memdelete(*type);
*type = nullptr;
}
gdtype_autorelease_pool.clear();
}
// Array to use in optional parameters on methods and the DEFVAL_ARRAY macro.