diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2023-03-13 09:13:34 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2023-03-13 09:13:34 +0100 |
commit | c98e0335bb29888c08d05f3ae1e0e1263026f2a0 (patch) | |
tree | 8a909495e1a9d9dda012a8b954342abfecaae68a /codegen | |
parent | c2093183099e4da3e00da38a3a6de18c319f4c87 (diff) | |
download | vala-c98e0335bb29888c08d05f3ae1e0e1263026f2a0.tar.gz |
codegen: Use g_object_class_override_property to implement generic interface properties
This caused the criticals like:
GLib-GObject-CRITICAL **: Read/writable property 'data' on class 'Foo' has type
'gchararray' which is not exactly equal to the type 'gpointer' of the property on
the interface 'IFoo'
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1419
Diffstat (limited to 'codegen')
-rw-r--r-- | codegen/valagobjectmodule.vala | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala index 457e7f2de..e2179f1f4 100644 --- a/codegen/valagobjectmodule.vala +++ b/codegen/valagobjectmodule.vala @@ -142,12 +142,28 @@ public class Vala.GObjectModule : GTypeModule { ccode.add_statement (new CCodeComment (prop.comment.content)); } - var cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_install_property")); + var cinst = new CCodeFunctionCall (); cinst.add_argument (ccall); cinst.add_argument (new CCodeConstant ("%s_PROPERTY".printf (get_ccode_upper_case_name (prop)))); - cinst.add_argument (get_param_spec (prop)); - ccode.add_expression (cinst); + //TODO g_object_class_override_property should be used more regulary + unowned Property? base_prop = prop.base_interface_property; + if (base_prop != null && base_prop.property_type is GenericType) { + cinst.call = new CCodeIdentifier ("g_object_class_override_property"); + cinst.add_argument (get_property_canonical_cconstant (prop)); + + ccode.add_expression (cinst); + + var cfind = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_find_property")); + cfind.add_argument (ccall); + cfind.add_argument (get_property_canonical_cconstant (prop)); + ccode.add_expression (new CCodeAssignment (get_param_spec_cexpression (prop), cfind)); + } else { + cinst.call = new CCodeIdentifier ("g_object_class_install_property"); + cinst.add_argument (get_param_spec (prop)); + + ccode.add_expression (cinst); + } } } |