mAlphaFunction(AlphaFunction::DEFAULT),
mDisconnectAction(Dali::Animation::BakeFinal),
mActive(false),
- mEnabled(true)
+ mEnabled(true),
+ mConnectedToSceneGraph(false)
{
}
}
/**
+ * Called when Animator is added to the scene-graph in update-thread.
+ */
+ virtual void ConnectToSceneGraph() = 0;
+
+ /**
* Set the duration of the animator.
* @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
* @param [in] seconds Duration in seconds.
Dali::Animation::EndAction mDisconnectAction; ///< EndAction to apply when target object gets disconnected from the stage.
bool mActive:1; ///< Animator is "active" while it's running.
bool mEnabled:1; ///< Animator is "enabled" while its target object is valid and on the stage.
+ bool mConnectedToSceneGraph:1; ///< True if ConnectToSceneGraph() has been called in update-thread.
};
/**
*/
virtual ~Animator()
{
- if (mPropertyOwner)
+ if (mPropertyOwner && mConnectedToSceneGraph)
{
mPropertyOwner->RemoveObserver(*this);
}
}
/**
+ * Called when Animator is added to the scene-graph in update-thread.
+ */
+ virtual void ConnectToSceneGraph()
+ {
+ mConnectedToSceneGraph = true;
+ mPropertyOwner->AddObserver(*this);
+ }
+
+ /**
* Called when mPropertyOwner is connected to the scene graph.
*/
virtual void PropertyOwnerConnected( PropertyOwner& owner )
mAnimatorFunction( animatorFunction ),
mCurrentProgress( 0.0f )
{
- mPropertyOwner->AddObserver(*this);
+ // WARNING - this object is created in the event-thread
+ // The scene-graph mPropertyOwner object cannot be observed here
}
// Undefined