summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/opengl/qglframebufferobject.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index 9659654..859afc7 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -875,9 +875,12 @@ QImage QGLFramebufferObject::toImage() const
if (!d->valid)
return QImage();
- const_cast<QGLFramebufferObject *>(this)->bind();
+ bool wasBound = isBound();
+ if (!wasBound)
+ const_cast<QGLFramebufferObject *>(this)->bind();
QImage image = qt_gl_read_framebuffer(d->size, d->ctx->format().alpha(), true);
- const_cast<QGLFramebufferObject *>(this)->release();
+ if (!wasBound)
+ const_cast<QGLFramebufferObject *>(this)->release();
return image;
}