summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2011-06-08 17:52:28 +0100
committerRobert Bragg <robert@linux.intel.com>2011-06-13 17:48:23 +0100
commitc603dc67ca13d26e3909196500da693a92654dee (patch)
treedb7029a833ea0d72e9376f1fa1dba0846a0409a9
parent3d2564df8f71d6030d9496b7f8e57a27905a4b5a (diff)
downloadcogl-c603dc67ca13d26e3909196500da693a92654dee.tar.gz
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.
-rw-r--r--cogl/cogl-vertex-buffer.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/cogl/cogl-vertex-buffer.c b/cogl/cogl-vertex-buffer.c
index afe67f11..4d0343e4 100644
--- a/cogl/cogl-vertex-buffer.c
+++ b/cogl/cogl-vertex-buffer.c
@@ -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 */