Merge pull request #67512 from rburing/opposite_of_abstract_is_concrete

Fix GDExtension classes derived from abstract GDExtension classes always being registered as abstract
This commit is contained in:
Yuri Sizov 2023-08-25 14:58:23 +02:00
commit fff32bb72a
1 changed files with 9 additions and 1 deletions

View File

@ -1661,7 +1661,15 @@ void ClassDB::register_extension_class(ObjectGDExtension *p_extension) {
c.name = p_extension->class_name;
c.is_virtual = p_extension->is_virtual;
if (!p_extension->is_abstract) {
c.creation_func = parent->creation_func;
// Find the closest ancestor which is either non-abstract or native (or both).
ClassInfo *concrete_ancestor = parent;
while (concrete_ancestor->creation_func == nullptr &&
concrete_ancestor->inherits_ptr != nullptr &&
concrete_ancestor->gdextension != nullptr) {
concrete_ancestor = concrete_ancestor->inherits_ptr;
}
ERR_FAIL_NULL_MSG(concrete_ancestor->creation_func, "Extension class " + String(p_extension->class_name) + " cannot extend native abstract class " + String(concrete_ancestor->name));
c.creation_func = concrete_ancestor->creation_func;
}
c.inherits = parent->name;
c.class_ptr = parent->class_ptr;