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 663914 - Clutter.Animator() does not work for 'x'/'y' properties
Clutter.Animator() does not work for 'x'/'y' properties
Status: RESOLVED WONTFIX
Product: pyclutter
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Pyclutter maintainer(s)
Pyclutter maintainer(s)
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2011-11-12 11:12 UTC by Andre Kuehne
Modified: 2018-08-17 19:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test python script to reproduce the observed behaviour (2.12 KB, text/x-python)
2011-11-12 11:12 UTC, Andre Kuehne
Details

Description Andre Kuehne 2011-11-12 11:12:09 UTC
Created attachment 201285 [details]
test python script to reproduce the observed behaviour

I am porting a pyclutter app to pygobject. Now i get these warnings:

Warning: g_value_set_float: assertion `G_VALUE_HOLDS_FLOAT (value)' failed

This happens when i use the Animator to change 'x'/'y' property of an Actor.
The animation does not work then, the actor does not move.
With other properties like scale-x/y this problem does not occur.
I suspect this has something to do with x/y being gfloat, e.g. scale-x/y (which works) is gdouble.

I used jhbuild with moduleset "gnome-suites-core-3.2" to build the modules "gtk+", "clutter" and "pygobject". "git describe" in checkout/gnome/pygobject says "3.0.2-11-g4f63721".

Attached is a test script to reproduce this. The files __doc__ does also contain the output it produces.
Comment 1 Tomeu Vizoso 2011-11-14 07:36:06 UTC
(In reply to comment #0)
> Created an attachment (id=201285) [details]
> test python script to reproduce the observed behaviour
> 
> I am porting a pyclutter app to pygobject. Now i get these warnings:
> 
> Warning: g_value_set_float: assertion `G_VALUE_HOLDS_FLOAT (value)' failed

I guess you need to pass a GValue with an specific type, like it's done in:

http://git.gnome.org/browse/pygobject/tree/tests/test_gi.py#n1007

Otherwise PyGObject will have to guess what type the API expects and it will get it wrong sometimes.
Comment 2 Andre Kuehne 2011-11-14 16:35:32 UTC
That does indeed work. Thanks.
Comment 3 Tomeu Vizoso 2011-11-14 17:08:08 UTC
(In reply to comment #2)
> That does indeed work. Thanks.

The it would be good to either close this bug, or move it to clutter with a suggestion for improving the bindings, as bugzilla isn't a support forum :)
Comment 4 Andre Kuehne 2011-11-14 17:56:22 UTC
I only filed this as a bug because someone on IRC suggested I do so.
Since it turns out not to be a bug at all, sure this can be closed.

On the other hand I agree that the bindings could be improved in this regard at least from a user POV. The solution feels like a low level workaround in Python.
Comment 5 johnp 2011-11-14 18:28:38 UTC
Ah, yes this can be fixed in clutter by providing overrides, however there really is no good way to fix generic interfaces that take GValues when dealing with similar types such as float and double.  The only fix when dealing with GValues is to specify the type explicitly.  Variants have a slightly better way of dealing with this by giving type signatures but in the end of the data Variants and GValues both need to be wrapped so we know how to encode.

There is another "fix" which would be for the APIs to be a bit looser in what types they accept.  In other words if an interface expects a float but gets a double it could decide to cast and throw an error only if there is an overflow.  That is up to the clutter devs though.
Comment 6 Emmanuele Bassi (:ebassi) 2011-11-18 12:50:11 UTC
I don't think it's Clutter's role to decide this. we use the type of the property to initialise the GValue, and we use the GValue API after that; if we decided to do some sort of coercion on the type then we'd also have to do int-to-float, int64-to-float, etc. and it's not always doable in a language-neutral way.

Python doesn't have a concept of float/double, so it should be the one that does the coercion when it gets to the C level, given that it's the layer that can actually raise an exception if the range is not valid (GObject will either silently discard it, with or without a warning on the terminal).
Comment 7 Tomeu Vizoso 2011-11-18 14:09:35 UTC
(In reply to comment #6)
> I don't think it's Clutter's role to decide this. we use the type of the
> property to initialise the GValue, and we use the GValue API after that; if we
> decided to do some sort of coercion on the type then we'd also have to do
> int-to-float, int64-to-float, etc. and it's not always doable in a
> language-neutral way.
> 
> Python doesn't have a concept of float/double, so it should be the one that
> does the coercion when it gets to the C level, given that it's the layer that
> can actually raise an exception if the range is not valid (GObject will either
> silently discard it, with or without a warning on the terminal).

I think that when J5 said Clutter, he meant pyclutter. It cannot be in PyGObject itself because it's specific to the API that is being bound and PyGObject cannot depend on every API it can be used to call.
Comment 8 johnp 2011-11-18 18:07:51 UTC
The issue is clutter expects a certain type but the interface has no way of exporting that unlike the properties interface which works because we special case set_property.  Unfortunately for any other interface which takes properties there is no way for introspection to know that it should grab the property type to know how to marshal it.  Perhaps we should have a property annotation but then how would list of properties work?

Python can't do anything here if it doesn't know the parameters are properties, however an override should be able to handle wrapping the GValue.  Failing that users will have to understand the GValue API in order to use the interface.
Comment 9 johnp 2011-11-18 19:37:14 UTC
Two other "fixes" which we used in python-dbus were:

1) Create a wrapper object for each supported type - e.g. glib.Float(2.1) glib.Int64(999999999999999) which our marshallers could explicitly cast.  This is much nicer than the GValue API but in dbus we felt it was a bit verbose.

2) allow passing of type strings - e.g. _signature="sf" - this is similar to how the Variant API works and we would use the Variant format for type representation.

I like option 1 as the better of two evils because it is easier to implement and is only used for edge cases. Option 2 would tie in nicely with Variants and D-Bus but isn't immediately readable by the casual pygobject developer.

In any case, I don't have any time to implement this but if someone wanted to I can tell them where to look.h
Comment 10 Emmanuele Bassi (:ebassi) 2012-08-15 13:34:35 UTC
re-assigning, sorry for the spam.
Comment 11 André Klapper 2018-08-17 19:17:49 UTC
gnome-phone-manager is not under active development anymore since 2015.
Its codebase has been archived:
https://gitlab.gnome.org/Archive/pyclutter/commits/master

Closing this report as WONTFIX as part of Bugzilla Housekeeping to reflect
reality. Please feel free to reopen this ticket (or rather transfer the project
to GNOME Gitlab, as GNOME Bugzilla is deprecated) if anyone takes the
responsibility for active development again.