summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2011-06-08 17:52:28 +0100
committerEmmanuele Bassi <ebassi@linux.intel.com>2011-06-14 13:54:42 +0100
commit16a0b84bca35e232d24762821ad7ea0ff5de0d5f (patch)
tree168c693d6398d90498413d25e6a12b170831c4df
parentde1114ffd9b65088f5119a9b7674d1bb8ff98a0e (diff)
downloadclutter-16a0b84bca35e232d24762821ad7ea0ff5de0d5f.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. Cherry-picked from Cogl's commit: c603dc67ca13d26e3909196500da693a92654dee
-rw-r--r--clutter/cogl/cogl/cogl-vertex-buffer.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/clutter/cogl/cogl/cogl-vertex-buffer.c b/clutter/cogl/cogl/cogl-vertex-buffer.c
index f9fac148c..22c02b415 100644
--- a/clutter/cogl/cogl/cogl-vertex-buffer.c
+++ b/clutter/cogl/cogl/cogl-vertex-buffer.c
@@ -1497,6 +1497,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 */