summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}