Fixed crashes in QGLTextureDestroyer.

QGLTextureDestroyer will try to make the context current on the GUI
thread, regardless of whether it is owned by another thread. Use
QOpenGLSharedResourceGuard instead which does the right thing and takes
shared contexts into account.

Task-number: QTBUG-31403
Change-Id: I1377f9284995a7ba5af32c85296eef152fc035c8
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
This commit is contained in:
Samuel Rødal 2013-05-28 15:43:05 +02:00 committed by The Qt Project
parent 81e981a704
commit 72768c089a
2 changed files with 7 additions and 19 deletions

View File

@ -1579,10 +1579,7 @@ QGLContextPrivate::QGLContextPrivate(QGLContext *context)
{
group = new QGLContextGroup(context);
if (qApp) {
texture_destroyer = new QGLTextureDestroyer;
texture_destroyer->moveToThread(qApp->thread());
}
texture_destroyer = new QGLTextureDestroyer;
}
QGLContextPrivate::~QGLContextPrivate()

View File

@ -335,25 +335,16 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(GLuint)
QT_BEGIN_NAMESPACE
class Q_OPENGL_EXPORT QGLTextureDestroyer : public QObject
class Q_OPENGL_EXPORT QGLTextureDestroyer
{
Q_OBJECT
public:
QGLTextureDestroyer() : QObject() {
connect(this, SIGNAL(freeTexture(QGLContext *, QPlatformPixmap *, quint32)),
this, SLOT(freeTexture_slot(QGLContext *, QPlatformPixmap *, quint32)));
}
void emitFreeTexture(QGLContext *context, QPlatformPixmap *boundPixmap, GLuint id) {
emit freeTexture(context, boundPixmap, id);
void emitFreeTexture(QGLContext *context, QPlatformPixmap *, GLuint id) {
if (context->contextHandle())
(new QOpenGLSharedResourceGuard(context->contextHandle(), id, freeTextureFunc))->free();
}
Q_SIGNALS:
void freeTexture(QGLContext *context, QPlatformPixmap *boundPixmap, quint32 id);
private slots:
void freeTexture_slot(QGLContext *context, QPlatformPixmap *boundPixmap, quint32 id) {
Q_UNUSED(boundPixmap);
QGLShareContextScope scope(context);
private:
static void freeTextureFunc(QOpenGLFunctions *, GLuint id) {
glDeleteTextures(1, &id);
}
};