From 693050b667bf8ee75e15a6d42b6a47d334d3cd2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 6 Oct 2022 05:35:47 +0200 Subject: 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. --- gi/object.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gi') 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); -- cgit v1.2.1