[vala/wip/issue/1121] vala: Don't allow assigning GtkChild fields/properties
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/issue/1121] vala: Don't allow assigning GtkChild fields/properties
- Date: Sat, 16 Jan 2021 13:32:49 +0000 (UTC)
commit 1794ac7b4e9e5b3a75305aa443902cc3d626becd
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Jan 16 10:05:30 2021 +0100
vala: Don't allow assigning GtkChild fields/properties
These are handled exclusively by GtkBuilder
See https://gitlab.gnome.org/GNOME/vala/issues/1121
vala/valaassignment.vala | 6 ++++++
vala/valaproperty.vala | 7 ++++++-
vala/valaunaryexpression.vala | 5 +++++
3 files changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala
index 79090ad9b..4ffc75735 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -178,6 +178,12 @@ public class Vala.Assignment : Expression {
return false;
}
+ if (ma.symbol_reference.get_attribute ("GtkChild") != null) {
+ error = true;
+ Report.error (source_reference, "Assignment of [GtkChild] `%s' is not
allowed", ma.symbol_reference.get_full_name ());
+ return false;
+ }
+
if (ma.symbol_reference is DynamicProperty) {
// target_type not available for dynamic properties
} else {
diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala
index 2fc1b4d60..163a1bb0a 100644
--- a/vala/valaproperty.vala
+++ b/vala/valaproperty.vala
@@ -492,7 +492,12 @@ public class Vala.Property : Symbol, Lockable {
get_accessor.check (context);
}
if (set_accessor != null) {
- set_accessor.check (context);
+ if (get_attribute ("GtkChild") != null) {
+ Report.warning (set_accessor.source_reference, "[GtkChild] property `%s' is
not allowed to have `set' accessor", get_full_name ());
+ set_accessor = null;
+ } else {
+ set_accessor.check (context);
+ }
}
if (initializer != null && field == null && !is_abstract) {
diff --git a/vala/valaunaryexpression.vala b/vala/valaunaryexpression.vala
index 76c31cd7a..4bf6d4bc4 100644
--- a/vala/valaunaryexpression.vala
+++ b/vala/valaunaryexpression.vala
@@ -229,6 +229,11 @@ public class Vala.UnaryExpression : Expression {
Report.error (source_reference, "ref and out method arguments can only be
used with fields, parameters, local variables, and array element access");
return false;
}
+ if (inner.symbol_reference.get_attribute ("GtkChild") != null) {
+ error = true;
+ Report.error (source_reference, "Assignment of [GtkChild] `%s' is not
allowed", inner.symbol_reference.get_full_name ());
+ return false;
+ }
break;
default:
error = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]