summaryrefslogtreecommitdiffstats
path: root/core/object
diff options
context:
space:
mode:
authorRicardo Buring <ricardo.buring@gmail.com>2022-10-17 00:22:10 +0200
committerRicardo Buring <ricardo.buring@gmail.com>2023-08-22 09:53:03 +0200
commitacf9d4e4de2f3601dd917b51390cceb32600df9d (patch)
tree37040e6cb61451012dc743a078e3d4e1fc74697f /core/object
parent8e0346badefcd69656e1ae3ba12d6eaafd7a4fae (diff)
downloadredot-engine-acf9d4e4de2f3601dd917b51390cceb32600df9d.tar.gz
Fix GDExtension classes derived from abstract GDExtension classes always being registered as abstract
Diffstat (limited to 'core/object')
-rw-r--r--core/object/class_db.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index c8c50fb957..e9fd8ad583 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -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;