-
Notifications
You must be signed in to change notification settings - Fork 19
Fix bad custom animation example #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
C-D-Lewis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This caught me a few times 👍
|
I think you should make the |
Sorixelle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just needs a Signed-off-by and it's good to go!
If I'm going to do a larger change, it would include both creating and destroying the Animation* variable. Just making it static isn't very useful (and it's allocated on the heap, so it doesn't have the scope problems that AnimationImplmentation has). |
889a2fc to
169b710
Compare
|
I updated the example to be more "complete", and hopefully representitive of how people will actually use it. |
The custom animation example suggests that a stack-allocated AnimationImplementation variable can be used, but this is incorrect. The variable is not copied and so must remain valid while the animation runs. Rework the example to use a global variable for the implementation. Signed-off-by: Lincoln Ramsay <a1291762@gmail.com>
7065cff to
7e0a605
Compare
|
The custom animation example suggests that a stack-allocated AnimationImplementation variable can be used, but this is incorrect. The variable is not copied and so must remain valid while the animation runs.
For brevity, I have used a static qualifier to give the variable global lifespan without making it an explicit global variable.
I have also added a note about the lifetime of the AnimationImplementation variable.
The API documentation is not clear, and following this example led me to a crashing app. I am seemingly not the only one that has had this happen. See https://stackoverflow.com/questions/35661791/pebble-how-to-create-a-custom-animation for the same problem (though it's not clear if they also based their code on the example).