Cannot access animate-properties in Clutter

163 views Asked by At

I am trying to animate an actor in Clutter, but when I enter a property that exists, something goes wrong.

actor.animate( AnimationMode.LINEAR, 400, scale_x:2);

gives me this error

Clutter-WARNING **: Cannot bind property '\x83\xec\u0014\x89\xc6e\xa1\u000c': objects of type 'ClutterTexture' do not have this property

Looks like Unicode-characters to me. However, when I enter a property that does NOT exist

actor.animate( AnimationMode.LINEAR, 400, thisdoesntwork:2);

I get an error that makes much more sense

Clutter-WARNING **: Cannot bind property 'thisdoesntwork': objects of type 'ClutterTexture' do not have this property

I get the exact same problem when I try this alternative approach:

actor.animate( AnimationMode.LINEAR, 400, "scale-x", 2);

How come all properties that actually exist get converted to some mess, and what can I do to get this to work?

1

There are 1 answers

0
nemequ On BEST ANSWER

You should be using 2.0 for the value, not 2. 2 is an integer, 2.0 is a double. Vala can't provide type safety for variadic methods, so you have to be careful.

As for why you're seeing the behavior you are for properties which exist, my guess is it has to do with the fact that 2 is a (32-bit) integer and 2.0 is a (64-bit) double. This is simplifying things a bit, and I don't know how much experience you have with C (probably not a lot, since this is the sort of mistake someone coming from a dynamically typed language would make), however... Clutter (well, va_arg) expects a double so it parses 64 bits of data, but you only provided 32 bits, so the first 32-bits of the next argument (NULL) are included. Now, when it starts trying to parse the next argument it starts from the wrong location (32-bits into the argument), so you get the the remainder of NULL and part of whatever garbage happened to be on the stack... Unsuprisingly, that doesn't just so happen to be 32-bits of 0s so when Clutter tests to see if the value it just read == NULL it isn't and Clutter thinks it's been given a pointer to an null-terminated array of characters (which is how strings are represented in C). It reads the data at that location, which just so happens to be \x83\xec\u0014\x89\xc6e\xa1\u000c, and checks to see if there is a property with that name. There isn't, so it emits the error message you saw.

Now, if you switch to using a property which doesn't exist, Clutter will parse the argument (the name of the property), notice that it doesn't exist (just like it did with the second property above), and emit an error.