Memory leak:
If a public API TextureSet gets deleted, it sends a
message to update-manager (RemoveTextureSet).
The scene graph side TextureSet gets removed from
update manager, but it never gets deleted.
Invalid memory access:
Currently when a scene graph TextureSet gets deleted
the renderers using that TextureSet are not notified.
So when a Render gets deleted it would call
TextureSet->RemoveObserver( this );
on an already deleted TextureSet.
DALi however doesn't crash at this point,
because the TextureSet is stored in a memory
pool so the object is still reachable.
Change-Id: Icf0f5a3e55d3ba7537f40db08accad04ae4440f7
if( textureSet == mImpl->textureSets[i] )
{
mImpl->textureSets.Remove( mImpl->textureSets.Begin() + i );
+
+ // Update manager has ownership of the TextureSet
+ delete textureSet;
return;
}
}
mResendFlag |= RESEND_DATA_PROVIDER;
}
+void Renderer::TextureSetDeleted()
+{
+ mTextureSet = NULL;
+
+ mResendFlag |= RESEND_DATA_PROVIDER;
+}
void Renderer::ConnectionsChanged( PropertyOwner& object )
{
// One of our child objects has changed it's connections. Ensure the uniform
void Renderer::ObservedObjectDestroyed(PropertyOwner& owner)
{
- if( reinterpret_cast<PropertyOwner*>(mTextureSet) == &owner )
- {
- mTextureSet = NULL;
- }
- else if( reinterpret_cast<PropertyOwner*>(mShader) == &owner )
+ if( reinterpret_cast<PropertyOwner*>(mShader) == &owner )
{
mShader = NULL;
}
*/
void TextureSetChanged();
+ /**
+ * Called by the TextureSet to notify to the renderer that it is about to be deleted
+ */
+ void TextureSetDeleted();
+
public: // Implementation of ObjectOwnerContainer template methods
/**
* Connect the object to the scene graph
TextureSet::~TextureSet()
{
+ size_t rendererCount = mRenderers.Size();
+ for( size_t i(0); i<rendererCount; ++i )
+ {
+ mRenderers[i]->TextureSetDeleted();
+ }
}
void TextureSet::operator delete( void* ptr )