Skip to content

Commit

Permalink
Merge pull request #67512 from rburing/opposite_of_abstract_is_concrete
Browse files Browse the repository at this point in the history
Fix GDExtension classes derived from abstract GDExtension classes always being registered as abstract
  • Loading branch information
YuriSizov committed Aug 25, 2023
2 parents 6758a7f + acf9d4e commit fff32bb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/object/class_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fff32bb

Please sign in to comment.