Fix a crash when calling QOpenGLTexture::setData with a null QImage.
Change-Id: Idf8ae00cff6929114b38dcb003c259c83a11dbaa Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
This commit is contained in:
parent
6e14d63db0
commit
672f7dfdcd
@ -3050,6 +3050,12 @@ void QOpenGLTexture::setData(const QImage& image, MipMapGeneration genMipMaps)
|
||||
qWarning("QOpenGLTexture::setData() requires a valid current context");
|
||||
return;
|
||||
}
|
||||
|
||||
if (image.isNull()) {
|
||||
qWarning("QOpenGLTexture::setData() tried to set a null image");
|
||||
return;
|
||||
}
|
||||
|
||||
if (context->isOpenGLES() && context->format().majorVersion() < 3)
|
||||
setFormat(QOpenGLTexture::RGBAFormat);
|
||||
else
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <QtGui/QOpenGLVertexArrayObject>
|
||||
#include <QtGui/QOpenGLBuffer>
|
||||
#include <QtGui/QOpenGLPaintDevice>
|
||||
#include <QtGui/QOpenGLTexture>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QScreen>
|
||||
#include <QtGui/QWindow>
|
||||
@ -97,8 +98,8 @@ private slots:
|
||||
void textureblitterFullTargetRectTransform();
|
||||
void textureblitterPartTargetRectTransform();
|
||||
void defaultSurfaceFormat();
|
||||
|
||||
void imageFormatPainting();
|
||||
void nullTextureInitializtion();
|
||||
|
||||
#ifdef USE_GLX
|
||||
void glxContextWrap();
|
||||
@ -1367,6 +1368,18 @@ void tst_QOpenGL::bufferMapRange()
|
||||
ctx->doneCurrent();
|
||||
}
|
||||
|
||||
void tst_QOpenGL::nullTextureInitializtion()
|
||||
{
|
||||
QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
|
||||
QOpenGLContext ctx;
|
||||
ctx.create();
|
||||
ctx.makeCurrent(surface.data());
|
||||
|
||||
QImage i;
|
||||
QOpenGLTexture t(i);
|
||||
QVERIFY(!t.isCreated());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QOpenGL)
|
||||
|
||||
#include "tst_qopengl.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user