+ delete mAnimatorFunction;
+ if (mPropertyOwner && mConnectedToSceneGraph)
+ {
+ mPropertyOwner->RemoveObserver(*this);
+ }
+ if( mLifecycleObserver != nullptr )
+ {
+ mLifecycleObserver->ObjectDestroyed();
+ }
+ }
+
+ void AddLifecycleObserver( LifecycleObserver& observer )
+ {
+ mLifecycleObserver = &observer;
+ }
+
+ void RemoveLifecycleObserver( LifecycleObserver& observer )
+ {
+ mLifecycleObserver = nullptr;
+ }
+
+private: // From PropertyOwner::Observer
+
+ /**
+ * @copydoc PropertyOwner::Observer::PropertyOwnerConnected( PropertyOwner& owner )
+ */
+ void PropertyOwnerConnected( PropertyOwner& owner ) override final
+ {
+ mEnabled = true;
+ }
+
+ /**
+ * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
+ */
+ void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner ) override final
+ {
+ // If we are active, then bake the value if required
+ if ( mAnimationPlaying && mDisconnectAction != Dali::Animation::Discard )
+ {
+ // Bake to target-value if BakeFinal, otherwise bake current value
+ Update( bufferIndex, ( mDisconnectAction == Dali::Animation::Bake ? mCurrentProgress : 1.0f ), true );
+ }
+
+ mEnabled = false;
+ }
+
+ /**
+ * @copydoc PropertyOwner::Observer::PropertyOwnerDestroyed( PropertyOwner& owner )
+ */
+ void PropertyOwnerDestroyed( PropertyOwner& owner ) override final
+ {
+ mPropertyOwner = nullptr;
+ }
+
+public:
+ /**
+ * Called when Animator is added to the scene-graph in update-thread.
+ */
+ void ConnectToSceneGraph()
+ {
+ mConnectedToSceneGraph = true;
+ mPropertyOwner->AddObserver(*this);