diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-10-01 03:02:49 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-10-01 03:17:04 (GMT) |
commit | 69e8fd3359a72230d377513b0314e64b5b83b712 (patch) | |
tree | e5318295a62d12254d16deaeb6b42b718bad9d93 /src/opengl/qglframebufferobject_p.h | |
parent | e8fc662c4b5a0fa5da6f0d47e1dbb5b2640d7001 (diff) | |
download | Qt-69e8fd3359a72230d377513b0314e64b5b83b712.zip Qt-69e8fd3359a72230d377513b0314e64b5b83b712.tar.gz Qt-69e8fd3359a72230d377513b0314e64b5b83b712.tar.bz2 |
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.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h index f80209d..055a752 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(); } }; |