[vala/0.40] vala: No-accessor struct properties in GLib.Object class must be owned
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] vala: No-accessor struct properties in GLib.Object class must be owned
- Date: Wed, 9 Oct 2019 17:36:11 +0000 (UTC)
commit 91a7f7d1c9980e969e78ea2112060bd8153dc7c9
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu May 9 10:17:36 2019 +0200
vala: No-accessor struct properties in GLib.Object class must be owned
Real structs are returned as heap-allocated structor by g_object_get() and
not defining them with owned getter results in memory leaks.
Additionally force DelegateType, PointerType and ValueType as unowned to
preserve the current behaviour for binding generation.
vala/valapropertyaccessor.vala | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
---
diff --git a/vala/valapropertyaccessor.vala b/vala/valapropertyaccessor.vala
index 81981b84a..79227e23d 100644
--- a/vala/valapropertyaccessor.vala
+++ b/vala/valapropertyaccessor.vala
@@ -158,6 +158,24 @@ public class Vala.PropertyAccessor : Subroutine {
value_parameter = new Parameter ("value", value_type, source_reference);
}
+ if (readable && ((TypeSymbol) prop.parent_symbol).is_subtype_of
(context.analyzer.object_type)) {
+ //FIXME Code duplication with CCodeMemberAccessModule.visit_member_access()
+ if (prop.get_attribute ("NoAccessorMethod") != null) {
+ if (value_type.is_real_struct_type ()) {
+ if (source_reference == null || source_reference.file == null) {
+ // Hopefully good as is
+ } else if (!value_type.value_owned && source_reference.file.file_type
== SourceFileType.SOURCE) {
+ Report.warning (source_reference, "unowned return value for
getter of property `%s' not supported without accessor".printf (prop.get_full_name ()));
+ value_type.value_owned = true;
+ }
+ } else if (value_type.value_owned && (source_reference == null ||
source_reference.file == null)) {
+ if (value_type is DelegateType || value_type is PointerType ||
(value_type is ValueType && !value_type.nullable)) {
+ value_type.value_owned = false;
+ }
+ }
+ }
+ }
+
if (prop.source_type == SourceFileType.SOURCE) {
if (body == null && !prop.interface_only && !prop.is_abstract) {
/* no accessor body specified, insert default body */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]