[vala/0.48] vala: Using SignalHandler.disconnect() is required for dynamic signals
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] vala: Using SignalHandler.disconnect() is required for dynamic signals
- Date: Sun, 14 Nov 2021 12:15:29 +0000 (UTC)
commit b6642b047a975c57a19dd34db5df88eaf1f67cd9
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Nov 1 14:02:04 2021 +0100
vala: Using SignalHandler.disconnect() is required for dynamic signals
tests/Makefile.am | 1 +
tests/objects/signals-dynamic-invalid-disconnect.test | 15 +++++++++++++++
vala/valamemberaccess.vala | 3 +++
3 files changed, 19 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 036c809b9..0ae4634a9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -515,6 +515,7 @@ TESTS = \
objects/signals-enum-marshal.vala \
objects/signals-delegate.vala \
objects/signals-delegate-parameter.vala \
+ objects/signals-dynamic-invalid-disconnect.test \
objects/signals-dymanic-invalid-handler.test \
objects/signals-dynamic-lambda-handler.test \
objects/signals-error-marshal.vala \
diff --git a/tests/objects/signals-dynamic-invalid-disconnect.test
b/tests/objects/signals-dynamic-invalid-disconnect.test
new file mode 100644
index 000000000..e1787ef24
--- /dev/null
+++ b/tests/objects/signals-dynamic-invalid-disconnect.test
@@ -0,0 +1,15 @@
+Invalid Code
+
+class Foo : Object {
+ public signal void sig ();
+}
+
+void sig_cb () {
+}
+
+void main () {
+ var real = new Foo ();
+ dynamic Object foo = real;
+
+ foo.sig.disconnect (sig_cb);
+}
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index 2a3abcfb8..10c59d34c 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -469,6 +469,9 @@ public class Vala.MemberAccess : Expression {
s.access = SymbolAccessibility.PUBLIC;
dynamic_object_type.type_symbol.scope.add (null, s);
symbol_reference = s;
+ } else if (ma.member_name == "disconnect") {
+ error = true;
+ Report.error (ma.source_reference, "Use
SignalHandler.disconnect() to disconnect from dynamic signal");
}
}
if (symbol_reference == null) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]