1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-13 13:31:48 +00:00

GDExtension: Prevent breaking compatibility for unexposed classes that can only be created once

(cherry picked from commit 2c707a911f)
This commit is contained in:
David Snopek
2025-09-30 14:34:46 -05:00
committed by Thaddeus Crews
parent c834443ef1
commit 2cb6d30dd1
4 changed files with 33 additions and 5 deletions

View File

@@ -545,6 +545,12 @@ Object *ClassDB::_instantiate_internal(const StringName &p_class, bool p_require
}
ERR_FAIL_NULL_V_MSG(ti, nullptr, vformat("Cannot get class '%s'.", String(p_class)));
ERR_FAIL_COND_V_MSG(ti->disabled, nullptr, vformat("Class '%s' is disabled.", String(p_class)));
#ifndef DISABLE_DEPRECATED
// Force legacy unexposed classes to skip the exposed check to preserve backcompat.
if (ti->gdextension && ti->gdextension->legacy_unexposed_class) {
p_exposed_only = false;
}
#endif // DISABLE_DEPRECATED
if (p_exposed_only) {
ERR_FAIL_COND_V_MSG(!ti->exposed, nullptr, vformat("Class '%s' isn't exposed.", String(p_class)));
}
@@ -604,6 +610,13 @@ bool ClassDB::_can_instantiate(ClassInfo *p_class_info, bool p_exposed_only) {
return false;
}
#ifndef DISABLE_DEPRECATED
// Force legacy unexposed classes to skip the exposed check to preserve backcompat.
if (p_class_info->gdextension && p_class_info->gdextension->legacy_unexposed_class) {
p_exposed_only = false;
}
#endif // DISABLE_DEPRECATED
if (p_exposed_only && !p_class_info->exposed) {
return false;
}