[gjs/299-can-not-access-gobject-properties-of-classes-without-gi-information] object: fix property regression
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/299-can-not-access-gobject-properties-of-classes-without-gi-information] object: fix property regression
- Date: Thu, 16 Jan 2020 22:28:11 +0000 (UTC)
commit 17e6abb9860600096d8e276d41949e4d9e46c098
Author: Juan Pablo Ugarte <ugarte endlessm com>
Date: Thu Jan 16 19:10:20 2020 -0300
object: fix property regression
Fallback to GType system for non custom GObject with no GI information
Fix issue https://gitlab.gnome.org/GNOME/gjs/issues/299
gi/object.cpp | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 75b1dd58..1ed95e00 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -651,7 +651,28 @@ bool ObjectPrototype::resolve_no_info(JSContext* cx, JS::HandleObject obj,
canonicalize_key(canonical_name);
}
- GType *interfaces = g_type_interfaces(m_gtype, &n_interfaces);
+ GjsAutoFree<GType> interfaces = g_type_interfaces(m_gtype, &n_interfaces);
+
+ /* Fallback to GType system for non custom GObjects with no GI information
+ */
+ if (canonical_name && G_TYPE_IS_CLASSED(m_gtype) &&
+ !g_type_get_qdata(m_gtype, ObjectInstance::custom_type_quark())) {
+ GjsAutoTypeClass<GObjectClass> oclass(m_gtype);
+
+ if (g_object_class_find_property(oclass, canonical_name))
+ return lazy_define_gobject_property(cx, obj, id, resolved, name);
+
+ for (i = 0; i < n_interfaces; i++) {
+ if (!G_TYPE_IS_CLASSED(interfaces[i]))
+ continue;
+
+ GjsAutoTypeClass<GObjectClass> iclass(interfaces[i]);
+
+ if (g_object_class_find_property(iclass, canonical_name))
+ return lazy_define_gobject_property(cx, obj, id, resolved, name);
+ }
+ }
+
for (i = 0; i < n_interfaces; i++) {
GjsAutoInterfaceInfo iface_info =
g_irepository_find_by_gtype(nullptr, interfaces[i]);
@@ -662,13 +683,10 @@ bool ObjectPrototype::resolve_no_info(JSContext* cx, JS::HandleObject obj,
g_interface_info_find_method(iface_info, name);
if (method_info) {
if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
- if (!gjs_define_function(cx, obj, m_gtype, method_info)) {
- g_free(interfaces);
+ if (!gjs_define_function(cx, obj, m_gtype, method_info))
return false;
- }
*resolved = true;
- g_free(interfaces);
return true;
}
}
@@ -679,14 +697,11 @@ bool ObjectPrototype::resolve_no_info(JSContext* cx, JS::HandleObject obj,
/* If the name refers to a GObject property, lazily define the property
* in JS as we do below in the real resolve hook. We ignore fields here
* because I don't think interfaces can have fields */
- if (is_ginterface_property_name(iface_info, canonical_name)) {
- g_free(interfaces);
+ if (is_ginterface_property_name(iface_info, canonical_name))
return lazy_define_gobject_property(cx, obj, id, resolved, name);
- }
}
*resolved = false;
- g_free(interfaces);
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]