mirror of
https://github.com/godotengine/godot.git
synced 2026-02-07 19:32:36 +00:00
Auto-release static GDTypes at exit.
This fixes "unclaimed StringName" warnings and improves engine shutdown correctness.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -234,6 +234,10 @@ public:
|
||||
static Array default_array_arg;
|
||||
static bool is_default_array_arg(const Array &p_array);
|
||||
|
||||
// Types added here will be automatically cleaned up on engine shutdown.
|
||||
// Only add types that aren't cleaned up in another way.
|
||||
static LocalVector<GDType **> gdtype_autorelease_pool;
|
||||
|
||||
private:
|
||||
// Non-locking variants of get_parent_class and is_parent_class.
|
||||
static StringName _get_parent_class(const StringName &p_class);
|
||||
|
||||
@@ -2383,8 +2383,10 @@ void Object::assign_type_static(GDType **type_ptr, const char *p_name, const GDT
|
||||
// Assigned while we were waiting.
|
||||
return;
|
||||
}
|
||||
type = memnew(GDType(super_type, StringName(p_name, true)));
|
||||
type = memnew(GDType(super_type, StringName(p_name)));
|
||||
*type_ptr = type;
|
||||
|
||||
ClassDB::gdtype_autorelease_pool.push_back(type_ptr);
|
||||
}
|
||||
|
||||
Object::~Object() {
|
||||
|
||||
Reference in New Issue
Block a user