summaryrefslogtreecommitdiffstats
path: root/src/opengl/qglframebufferobject_p.h
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-10-01 13:02:49 +1000
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-10-01 13:17:04 +1000
commit69e8fd3359a72230d377513b0314e64b5b83b712 (patch)
treee5318295a62d12254d16deaeb6b42b718bad9d93 /src/opengl/qglframebufferobject_p.h
parente8fc662c4b5a0fa5da6f0d47e1dbb5b2640d7001 (diff)
Make QGLFramebufferObject crash-proof if QGLContext destroyed first
Sometimes it isn't possible to arrange for the QGLFramebufferObject to be destroyed before the QGLContext group in which it was created. Especially during application shutdown or in applications with multiple shared contexts. This change modifies QGLFramebufferObject to use QGLSharedResourceGuard, which ensures that when the last QGLContext in a sharing group is destroyed, any remaining FBO's will revert to !isValid(). It is now safe to destroy the context before the FBO, or the FBO before the context. Unit test included. Reviewed-by: Sarah Smith
Diffstat (limited to 'src/opengl/qglframebufferobject_p.h')
-rw-r--r--src/opengl/qglframebufferobject_p.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h
index f80209d213..055a75229b 100644
--- a/src/opengl/qglframebufferobject_p.h
+++ b/src/opengl/qglframebufferobject_p.h
@@ -127,15 +127,15 @@ private:
class QGLFramebufferObjectPrivate
{
public:
- QGLFramebufferObjectPrivate() : depth_stencil_buffer(0), valid(false), ctx(0), previous_fbo(0), engine(0) {}
+ QGLFramebufferObjectPrivate() : fbo_guard(0), depth_stencil_buffer(0), valid(false), previous_fbo(0), engine(0) {}
~QGLFramebufferObjectPrivate() {}
void init(QGLFramebufferObject *q, const QSize& sz,
QGLFramebufferObject::Attachment attachment,
GLenum internal_format, GLenum texture_target, GLint samples = 0);
bool checkFramebufferStatus() const;
+ QGLSharedResourceGuard fbo_guard;
GLuint texture;
- GLuint fbo;
GLuint depth_stencil_buffer;
GLuint color_buffer;
GLenum target;
@@ -143,10 +143,11 @@ public:
QGLFramebufferObjectFormat format;
uint valid : 1;
QGLFramebufferObject::Attachment fbo_attachment;
- QGLContextGroup *ctx; // for Windows extension ptrs
GLuint previous_fbo;
mutable QPaintEngine *engine;
QGLFBOGLPaintDevice glDevice;
+
+ inline GLuint fbo() const { return fbo_guard.id(); }
};