From fae591b168b72b1a1f8ca9f0452bd0318ced36d5 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sun, 14 Nov 2010 22:59:24 -0500 Subject: [PATCH] Actually free buffer objects With the refactoring to centralize code into CoglBuffer, _cogl_buffer_fini() was never actually implemented, so all GL vertex and index buffer objects were leaked. The duplicate call to glDeleteBuffers() in CoglPixelArray is removed (it wasn't paying attention to whether the buffer had been allocated as a PBO or not.) http://bugzilla.clutter-project.org/show_bug.cgi?id=2423 --- cogl/cogl-buffer.c | 7 +++++++ cogl/cogl-pixel-array.c | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cogl/cogl-buffer.c b/cogl/cogl-buffer.c index a63e171f9..35234d9af 100644 --- a/cogl/cogl-buffer.c +++ b/cogl/cogl-buffer.c @@ -299,8 +299,15 @@ _cogl_buffer_initialize (CoglBuffer *buffer, void _cogl_buffer_fini (CoglBuffer *buffer) { + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + g_return_if_fail (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED)); g_return_if_fail (buffer->immutable_ref == 0); + + if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT) + GE( glDeleteBuffers (1, &buffer->gl_handle) ); + else + g_free (buffer->data); } /* OpenGL ES 1.1 and 2 have a GL_OES_mapbuffer extension that is able to map diff --git a/cogl/cogl-pixel-array.c b/cogl/cogl-pixel-array.c index 3f5e10a18..1ac9b08a8 100644 --- a/cogl/cogl-pixel-array.c +++ b/cogl/cogl-pixel-array.c @@ -147,8 +147,6 @@ _cogl_pixel_array_free (CoglPixelArray *buffer) /* parent's destructor */ _cogl_buffer_fini (COGL_BUFFER (buffer)); - GE( glDeleteBuffers (1, &(COGL_BUFFER (buffer)->gl_handle)) ); - g_slice_free (CoglPixelArray, buffer); }