summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2009-07-22 15:38:12 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2009-07-22 17:08:23 (GMT)
commit8768bcfa0000bc216a7f722cd82ac6b06b85a70d (patch)
treec5b75ce32eef1f92a1ba4909fbce5225afad532b /src/opengl
parentd1eca480acd39c478957e39243ff61b55c0113b4 (diff)
downloadQt-8768bcfa0000bc216a7f722cd82ac6b06b85a70d.zip
Qt-8768bcfa0000bc216a7f722cd82ac6b06b85a70d.tar.gz
Qt-8768bcfa0000bc216a7f722cd82ac6b06b85a70d.tar.bz2
Plug a texture leak when deleting QPixmaps without a current context
~QGLTexture wouldn't make the texture's context current if the current context was zero, meaning the texture would leak. This also means deleteBoundPixmap doesn't need to make the context currnet anymore (as it's only called from ~QGLTexture). Reviewed-By: Kim
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qgl_p.h11
-rw-r--r--src/opengl/qgl_x11.cpp14
2 files changed, 9 insertions, 16 deletions
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 01385f0..2ee3e1d 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -402,7 +402,7 @@ extern Q_OPENGL_EXPORT QGLShareRegister* qgl_share_reg();
class QGLTexture {
public:
QGLTexture(QGLContext *ctx = 0, GLuint tx_id = 0, GLenum tx_target = GL_TEXTURE_2D,
- bool _clean = true, bool _yInverted = false)
+ bool _clean = false, bool _yInverted = false)
: context(ctx), id(tx_id), target(tx_target), clean(_clean), yInverted(_yInverted)
#if defined(Q_WS_X11)
, boundPixmap(0)
@@ -413,14 +413,19 @@ public:
if (clean) {
QGLContext *current = const_cast<QGLContext *>(QGLContext::currentContext());
QGLContext *ctx = const_cast<QGLContext *>(context);
- bool switch_context = current && current != ctx && !qgl_share_reg()->checkSharing(current, ctx);
+ Q_ASSERT(ctx);
+ bool switch_context = current != ctx && !qgl_share_reg()->checkSharing(current, ctx);
if (switch_context)
ctx->makeCurrent();
#if defined(Q_WS_X11)
+ // Although glXReleaseTexImage is a glX call, it must be called while there
+ // is a current context - the context the pixmap was bound to a texture in.
+ // Otherwise the release doesn't do anything and you get BadDrawable errors
+ // when you come to delete the context.
deleteBoundPixmap();
#endif
glDeleteTextures(1, &id);
- if (switch_context)
+ if (switch_context && current)
current->makeCurrent();
}
}
diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp
index 0399b48..d8af4d5 100644
--- a/src/opengl/qgl_x11.cpp
+++ b/src/opengl/qgl_x11.cpp
@@ -1630,22 +1630,10 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pm, const qi
void QGLTexture::deleteBoundPixmap()
{
if (boundPixmap) {
- // Although glXReleaseTexImage is a glX call, it must be called while there
- // is a current context - the context the pixmap was bound to a texture in.
- // Otherwise the relese doesn't do anything and you get BadDrawable errors
- // when you come to delete the context.
-
- QGLContext *oldContext = const_cast<QGLContext*>(QGLContext::currentContext());
- if (oldContext != context)
- context->makeCurrent();
glXReleaseTexImageEXT(QX11Info::display(), boundPixmap, GLX_FRONT_LEFT_EXT);
- if (oldContext && oldContext != context)
- oldContext->makeCurrent();
-
glXDestroyPixmap(QX11Info::display(), boundPixmap);
+ boundPixmap = 0;
}
-
- boundPixmap = 0;
}