arturoc/ofxTween — pull request #10 by mitchmindtree (2014-02-01 15:13:20+00:00)
Title: Added copy constructor to ofxTween to handle ofxTween's dynamic allocations during copy.

Hey @arturoc / @obviousjim, thanks for the awesome addon!

Just thought I'd send a pull request for this as it has helped make the implementation of ofxTween in my own project much smoother.

All i've added is a copy constructor which handles the dynamic allocations when copying ofxTween objects or copying classes that contain ofxTweens (or placing classes with an ofxTween that exist on the stack into a vector). Previously, during the member-wise copy in the implicit copy constructor the address at easingFunction would be copied across - if the previous tween's destructor was called directly after it would free the memory at both it's easingFunction and the copy's easingFunction. The copy constructor simply makes sure each copy creates their own version of the easing and easingFunction rather than just copying the address. In the case that they are NULL, it makes sure that the copy's are also NULL.

Let me know if there was already a way around this, otherwise I hope it can help someone the way it's helped me!

Cheers