cogl-vertex-buffer: make sure to unref weak pipelines

When validating a user pipeline before drawing with a CoglVertexBuffer
we sometimes find we have to make some overrides and we handle that by
creating a pipeline which is a weak copy of the user pipeline. The weak
pipeline gets associated with the original pipeline so if that pipeline
is used multiple times then we can re-use the same override pipeline and
skip validation. Because it's a weak pipeline we get notified when the
original material is destroyed or changed so we know our weak pipeline
is now invalid.

When we get notified that the weak material is invalid we should unref
it, but instead we were just discarding our reference to it. This was
resulting in leaking weak materials and in some cases those materials
referenced textures which would then also be leaked.
This commit is contained in:
Robert Bragg 2011-06-08 17:52:28 +01:00
parent 3d2564df8f
commit c603dc67ca

View File

@ -1496,6 +1496,9 @@ weak_override_source_destroyed_cb (CoglPipeline *pipeline,
void *user_data)
{
VertexBufferMaterialPrivate *pipeline_priv = user_data;
/* Unref the weak pipeline copy since it is no longer valid - probably because
* one of its ancestors has been changed. */
cogl_object_unref (pipeline_priv->real_source);
pipeline_priv->real_source = NULL;
/* A reference was added when we copied the weak material so we need
to unref it here */