Fix GDExtension classes derived from abstract GDExtension classes always being registered as abstract

This commit is contained in:
Ricardo Buring 2022-10-17 00:22:10 +02:00
parent 8e0346bade
commit acf9d4e4de

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;