GNOME Bugzilla – Bug 615262
Type-ify notify connects
Last modified: 2018-05-22 13:32:34 UTC
Currently I can connect to property changes by using obj["prop_name"].connect( ... ); The problem with this syntax is, that I can connect to signals that do not exist or were deprecated and vanished. A solution would be to change the syntax, so a syntax check can be performed, two possibilities: obj.prop.connect( ... ) obj.notify.prop.connect( ... )
Created attachment 158271 [details] [review] warn about non existing property This patch warns about non existing property when using GObject notify signal as discussed on IRC.
Created attachment 159761 [details] [review] warn for non existing property for all type symbols This patch also takes in consideration interfaces.
Created attachment 159853 [details] [review] warn for non-existing property with is_gobject_property
Wonderful :)
*** Bug 619546 has been marked as a duplicate of this bug. ***
I don't think it's really a good idea to warn here. The signal detail can be an arbitrary runtime expression, which can't be checked anyway, and just like with Object.get/set_property you might want to use a property of a subclass that doesn't have bindings (e.g., useful with GStreamer elements). As long as the notify signal doesn't get special syntax, we should just leave it as it is, in my opinion.
The report does suggest a compile-time syntax, so I think the bug is still valid. I do in fact agree that it is not helpful to warn in the case of possibly unknown property names. To me it would be intuitive to have object.prop.connect. In case of doubt the signal should take precedence, and I humbly think it isn't worth supporting name conflicts.
To me this bug is still valid, as Christian points out, it would be good and intuitive to support something like object.prop.connect.
I think this kind of syntax can help: this.notify[property(you_property)].connect(); Where "property" is a keyword/operator returning a string that is the property name. This syntax has the advantage that there are no conflicts and a full compatibility with the old syntax. It can be implemented like "sizeof" or "typeof".
Keeping b/c is always a good way. Another alternative that came to my mind is using the property itself: this.notify[this.myprop].connect(…)
Yes, but it's not easy to implement. This method needs the property calling context. You can't directly recognize if an expression needs the getter or the property-name.
I agree with the object.prop.connect syntax, but rather being object.prop.connect_notify. This way, for dynamic objects, it is possible to distinguish between dynamic signals and dynamic properties.
I don't consider object.prop.connect_notify an acceptable solution. It suggests that connect_notify is a method of the property value, which is not correct.
Right, what about object.notify.prop.connect then?
Review of attachment 159853 [details] [review]: https://bugzilla.gnome.org/show_bug.cgi?id=615262#c6
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/84.