From: Rico Tzschichholz Date: Sat, 31 Mar 2018 19:45:03 +0000 (+0200) Subject: codegen: Apply G_PARAM_EXPLICIT_NOTIFY on properties with "notify = false" X-Git-Tag: 0.41.90~205 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02e91469f06c5497240f92cf6f9eb5b6c20aa0a9;p=thirdparty%2Fvala.git codegen: Apply G_PARAM_EXPLICIT_NOTIFY on properties with "notify = false" This requires --target-glib=2.42 to be passed. --- diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index 3e553ec7e..93f11da28 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -2016,6 +2016,9 @@ public class Vala.GTypeModule : GErrorModule { } } } + if (context.require_glib_version (2, 42) && !prop.notify) { + pflags = "%s%s".printf (pflags, " | G_PARAM_EXPLICIT_NOTIFY"); + } if (prop.version.deprecated) { pflags = "%s%s".printf (pflags, " | G_PARAM_DEPRECATED"); } diff --git a/tests/Makefile.am b/tests/Makefile.am index d4e4906df..0645f2f13 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -235,6 +235,7 @@ TESTS = \ objects/methods.vala \ objects/paramspec.vala \ objects/properties.vala \ + objects/property-notify.vala \ objects/regex.vala \ objects/signals.vala \ objects/signals-delegate.vala \ diff --git a/tests/objects/property-notify.vala b/tests/objects/property-notify.vala new file mode 100644 index 000000000..d2e02b27d --- /dev/null +++ b/tests/objects/property-notify.vala @@ -0,0 +1,36 @@ +class Foo : Object { + [CCode (notify = false)] + public string foo { get; set; } + + public string bar { get; set; } + + public string manam { get; set; } +} + +void fail () { + assert_not_reached (); +} + +int counter; +void count () { + counter++; +} + +void main () { + var foo = new Foo (); + + foo.notify["foo"].connect (fail); + //FIXME Requires --target-glib=2.42 for G_PARAM_EXPLICIT_NOTIFY to be actually added + //foo.set_property ("foo", "foo"); + foo.foo = "foo"; + + counter = 0; + foo.notify["bar"].connect (count); + foo.bar = "bar"; + assert (counter == 1); + + counter = 0; + foo.notify["manam"].connect (count); + foo.set_property ("manam", "manam"); + assert (counter == 1); +}