After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 693932 - Property changes not fired for uint, uint16 (and possibly other types)
Property changes not fired for uint, uint16 (and possibly other types)
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.18.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2013-02-16 02:40 UTC by Eric Gregory
Modified: 2017-09-21 12:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Sample program (1.09 KB, text/x-vala)
2013-02-16 02:40 UTC, Eric Gregory
  Details
codegen: Report error if property-type is not compatible with GLib.Object (5.19 KB, patch)
2017-03-27 12:24 UTC, Rico Tzschichholz
none Details | Review
codegen: Report warning if property-type is not compatible with GLib.Object (4.45 KB, patch)
2017-08-27 07:18 UTC, Rico Tzschichholz
none Details | Review
codegen: Report warning if property-type is not compatible with GLib.Object (4.45 KB, patch)
2017-09-12 10:09 UTC, Rico Tzschichholz
committed Details | Review
glib-2.0: Use type-id/marshaller-type for (u)int16/(u)short from (u)int32 (2.64 KB, patch)
2017-09-12 10:37 UTC, Rico Tzschichholz
committed Details | Review

Description Eric Gregory 2013-02-16 02:40:38 UTC
Created attachment 236332 [details]
Sample program

Vala's code generator doesn't create property change notifications for all types of properties.  This means the "notify" syntax can't be used for these types.

A sample program is attached.  The output of this program is:
int changed
string changed

The expected output is:
int changed
uint changed
uint16 changed
string changed

From examining the generated code, one can see that the calls to g_object_notify() are missing from the uint and uint16 setters.
Comment 1 Jim Nelson 2013-02-16 02:55:15 UTC
I noticed there's a bug in the minimal test case Eric attached.  testuint is declared as uint16.  testuint does fire a signal when changed to a uint.
Comment 2 Luca Bruno 2013-02-16 08:38:57 UTC
int16/uint16/short have no GType, your property is not even a gobject property.
Comment 3 Jim Nelson 2013-02-18 19:31:40 UTC
Are you saying this is by design?
Comment 4 Luca Bruno 2013-02-18 21:30:50 UTC
It's a limit of gobject. You can see the GType for fundamental types here: http://developer.gnome.org/gobject/stable/gobject-Type-Information.html#G-TYPE-INVALID:CAPS
Comment 5 Jim Nelson 2013-02-19 19:25:59 UTC
If the "notify::<name>" signal doesn't work for certain types of properties, I think it's a design flaw (or even a bug) that they can be made properties.  From a coder's point of view, there's no indication to me from the compiler that there's no signal for one property but there is for another.

I'm not 100% up on GType, but couldn't int16/uint16 be registered as types?  Would that solve this problem?

I would rather Vala not allow me as a programmer to create int16/uint16 properties and avoid this problem in the future than silently allow it and exhibit unexpected behavior.
Comment 6 Rico Tzschichholz 2017-03-27 12:24:05 UTC
Created attachment 348796 [details] [review]
codegen: Report error if property-type is not compatible with GLib.Object

Not all types are supported to be used for "real" Object-properties.
Therefore start to report an error instead of not registering it silently.
Comment 7 Daniel Espinosa 2017-03-27 12:36:36 UTC
I think this should not throws an Error, but automatically register a GType for property's​ type, when is possible.

So, if user wants to use an int64 instead an int, because makes more sense for its case, like in database applications, Vala should help by automatically register this data type. This is very common on libgda, it register it's required data types when needed.
Comment 8 Rico Tzschichholz 2017-03-27 14:14:59 UTC
> I think this should not throws an Error, but automatically register a GType
> for property's​ type, when is possible.

Seeing what impact it has, a warning would be more reasonable.

> So, if user wants to use an int64 instead an int

int64 is not a good example of yours since it has a GTtype G_TYPE_INT64 and therefore is valid and treated like that.
Comment 9 Daniel Espinosa 2017-03-27 14:23:18 UTC
(In reply to Rico Tzschichholz from comment #8)
> > I think this should not throws an Error, but automatically register a GType
> > for property's​ type, when is possible.
> 
> Seeing what impact it has, a warning would be more reasonable.
> 

Many thanks for this. May you can add a suggestion to register this type in order to get a fully working property.

> > So, if user wants to use an int64 instead an int
> 
> int64 is not a good example of yours since it has a GTtype G_TYPE_INT64 and
> therefore is valid and treated like that.

Sure you're right, I mean uint, for example.
Comment 10 Rico Tzschichholz 2017-08-27 07:18:18 UTC
Created attachment 358502 [details] [review]
codegen: Report warning if property-type is not compatible with GLib.Object

Not all types are supported to be used for "real" Object-properties.
Therefore start to report a warning instead of not registering it silently.
Comment 11 Rico Tzschichholz 2017-09-12 10:09:08 UTC
Created attachment 359598 [details] [review]
codegen: Report warning if property-type is not compatible with GLib.Object

Not all types are supported to be used for "real" Object-properties.
Therefore start to report a warning instead of not registering it silently.
Comment 12 Rico Tzschichholz 2017-09-12 10:37:51 UTC
Created attachment 359610 [details] [review]
glib-2.0: Use type-id/marshaller-type for (u)int16/(u)short from (u)int32
Comment 13 Rico Tzschichholz 2017-09-21 12:43:38 UTC
Attachment 359598 [details] pushed as 6aa600c - codegen: Report warning if property-type is not compatible with GLib.Object
Attachment 359610 [details] pushed as a8091c2 - glib-2.0: Use type-id/marshaller-type for (u)int16/(u)short from (u)int32