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



commit c603dc67ca13d26e3909196500da693a92654dee
Author: Robert Bragg <robert linux intel com>
Date:   Wed Jun 8 17:52:28 2011 +0100

    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.

 cogl/cogl-vertex-buffer.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/cogl/cogl-vertex-buffer.c b/cogl/cogl-vertex-buffer.c
index afe67f1..4d0343e 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 */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]