There was no way to tell if the property-owner was destroyed or removed from the scene as
different operations may be required for the two scenarios.
Change-Id: If291c2dc7762e1839dbcce346620d8814f94b4d3
}
/**
+ * Called when mPropertyOwner is disconnected from the scene graph.
+ */
+ virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
+ {
+ mPropertyOwner = NULL;
+ mPropertyAccessor.Reset();
+ }
+
+ /**
* Called shortly before mPropertyOwner is destroyed, along with its property.
*/
virtual void PropertyOwnerDestroyed( PropertyOwner& owner )
}
/**
+ * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected()
+ */
+ virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
+ {
+ PropertyOwnerDestroyed( owner );
+ }
+
+ /**
* @copydoc PropertyOwner::Observer::PropertyOwnerDestroyed()
*/
virtual void PropertyOwnerDestroyed( PropertyOwner& owner )
{
- // Discard pointer to destroyed property owner
- PropertyOwnerIter iter = mObservedOwners.find( &owner );
- DALI_ASSERT_DEBUG( mObservedOwners.end() != iter );
- mObservedOwners.erase( iter );
+ if ( !mDisconnected )
+ {
+ // Discard pointer to disconnected property owner
+ PropertyOwnerIter iter = mObservedOwners.find( &owner );
+ if( mObservedOwners.end() != iter )
+ {
+ mObservedOwners.erase( iter );
- // Stop observing the remaining property owners
- StopObservation();
+ // Stop observing the remaining property owners
+ StopObservation();
- // Notification for derived class
- OnDisconnect();
+ // Notification for derived class
+ OnDisconnect();
- mDisconnected = true;
+ mDisconnected = true;
+ }
+ }
}
/**
PropertyOwner::~PropertyOwner()
{
- DisconnectFromSceneGraph();
+ Destroy();
}
void PropertyOwner::AddObserver(Observer& observer)
return mObservers.Count() != 0u;
}
-void PropertyOwner::DisconnectFromSceneGraph()
+void PropertyOwner::Destroy()
{
// Notification for observers
const ConstObserverIter endIter = mObservers.End();
mConstraints.Clear();
}
+void PropertyOwner::DisconnectFromSceneGraph( BufferIndex updateBufferIndex )
+{
+ // Notification for observers
+ const ConstObserverIter endIter = mObservers.End();
+ for( ConstObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
+ {
+ (*iter)->PropertyOwnerDisconnected( updateBufferIndex, *this );
+ }
+
+ // Clear observers as they are not interested in destroyed if they have received a disconnect
+ mObservers.Clear();
+
+ // Remove all constraints when disconnected from scene-graph
+ mConstraints.Clear();
+}
+
void PropertyOwner::InstallCustomProperty(PropertyBase* property)
{
DALI_ASSERT_DEBUG( NULL != property );
public:
/**
+ * Called when the observable object is disconnected from the scene graph.
+ * @param[in] currentBufferIndex The buffer to reset.
+ * @post The observer is automatically disconnected
+ * (observer will not receive the PropertyOwnerDestroyed callback after this)
+ */
+ virtual void PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner ) = 0;
+
+ /**
* Called shortly before the observable object is destroyed.
+ *
+ * @note Cleanup should be done in both this and PropertyOwnerDisconnected as PropertyOwnerDisconnected
+ * may not be called (i.e. when shutting down).
*/
virtual void PropertyOwnerDestroyed( PropertyOwner& owner ) = 0;
};
bool IsObserved();
/**
+ * Called just before destruction to disconnect all observers and remove constraints.
+ * This occurs when the object is in the process of being destroyed.
+ */
+ void Destroy();
+
+ /**
* Disconnect all observers and remove constraints.
* This occurs when the object is disconnected from the scene-graph during UpdateManager::Update().
+ * @param[in] currentBufferIndex The current update buffer.
*/
- void DisconnectFromSceneGraph();
+ void DisconnectFromSceneGraph( BufferIndex updateBufferIndex );
/**
* Install a custom property.
{
}
+void MeshAttachment::PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
+{
+ // Bone node has been disconnected.
+}
+
void MeshAttachment::PropertyOwnerDestroyed( PropertyOwner& owner )
{
// Bone node has been destroyed.
BoneTransforms& boneTransforms );
private:
+
+ /**
+ * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected()
+ */
+ virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner );
+
/**
* @copydoc PropertyOwner::Observer::PropertyOwnerDestroyed()
*/
}
// Animators, Constraints etc. should be disconnected from the child's properties.
- PropertyOwner::DisconnectFromSceneGraph();
+ PropertyOwner::Destroy();
}
void Node::Attach( NodeAttachment& object )
}
// Animators, Constraints etc. should be disconnected from the child's properties.
- PropertyOwner::DisconnectFromSceneGraph();
+ PropertyOwner::DisconnectFromSceneGraph( updateBufferIndex );
// Remove back-pointer to parent
mParent = NULL;