summaryrefslogtreecommitdiff
path: root/cogl/cogl-framebuffer.c
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2009-11-25 14:26:32 +0000
committerRobert Bragg <robert@linux.intel.com>2010-01-08 20:42:35 +0000
commit05ce533fc8b865ed45f60abdf50625003b841576 (patch)
treee66b7d3289d86dc76540cf3dc71aeb8977c492c7 /cogl/cogl-framebuffer.c
parentfbad0a75b684cebbff874ba689810c2ff763b6e8 (diff)
downloadcogl-05ce533fc8b865ed45f60abdf50625003b841576.tar.gz
framebuffers: cogl_offscreen_new_to_texture should take a ref on the texture
We weren't taking a reference on the texture to be used as the color buffer for offscreen rendering, so it was possible to free the texture leaving the framebuffer in an inconsistent state.
Diffstat (limited to 'cogl/cogl-framebuffer.c')
-rw-r--r--cogl/cogl-framebuffer.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 585b6766..a34eaaa5 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -339,6 +339,7 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
offscreen->fbo_handle = fbo_gl_handle;
offscreen->gl_stencil_handle = gl_stencil_handle;
+ offscreen->texture = cogl_handle_ref (texhandle);
/* XXX: Can we get a away with removing this? It wasn't documented, and most
* users of the API are hopefully setting up the modelview from scratch
@@ -362,6 +363,8 @@ _cogl_offscreen_free (CoglOffscreen *offscreen)
if (offscreen->gl_stencil_handle)
GE (glDeleteRenderbuffers (1, &offscreen->gl_stencil_handle));
+ if (offscreen->texture != COGL_INVALID_HANDLE)
+ cogl_handle_unref (offscreen->texture);
GE (glDeleteFramebuffers (1, &offscreen->fbo_handle));
g_free (offscreen);
}