summaryrefslogtreecommitdiff
path: root/gi
diff options
context:
space:
mode:
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2022-10-06 05:35:47 +0200
committerPhilip Chimento <philip.chimento@gmail.com>2022-10-29 15:28:23 -0700
commit693050b667bf8ee75e15a6d42b6a47d334d3cd2c (patch)
treeca19c92d359bb493a1e07ed000b0898bd87e4e92 /gi
parent0dd4959658d51d5f27a776721f004d62da45fd05 (diff)
downloadgjs-693050b667bf8ee75e15a6d42b6a47d334d3cd2c.tar.gz
object: Try to lookup an object parent prototype from the parent gtype
In some cases we were not able to find the parent prototype by just looking at the saved gtypes, as they may be static types defined in C. This was leading to errors when initializing from static functions, so fix this.
Diffstat (limited to 'gi')
-rw-r--r--gi/object.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/gi/object.cpp b/gi/object.cpp
index 3ced434f..c9b00dbe 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -2070,6 +2070,12 @@ GIFieldInfo* ObjectPrototype::lookup_cached_field_info(JSContext* cx,
"Custom JS class must have parent");
ObjectPrototype* parent_proto =
ObjectPrototype::for_gtype(parent_gtype);
+
+ if (!parent_proto) {
+ JS::RootedObject proto(cx, gjs_lookup_object_prototype(cx, parent_gtype));
+ parent_proto = ObjectPrototype::for_js(cx, proto);
+ }
+
g_assert(parent_proto &&
"Custom JS class's parent must have been accessed in JS");
return parent_proto->lookup_cached_field_info(cx, key);