diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2023-03-17 15:03:54 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2023-03-21 11:55:53 +0100 |
commit | a561d52a8352f17f4a39bf54e0d3d9842c0d4064 (patch) | |
tree | f214cafaea9ad59cbbfe75df07655de37c7893bb /src/opengl/qopengltexture.cpp | |
parent | c0182c7817cb326d1b02ff8e7c75ed011d82d39f (diff) |
Add QImage null check when QOpenGLTexture converts
...the image to RGBA8888. Just mirror the first null check that is
done for the user-provided QImage. The same should be done for the
result of convertToFormat().
Pick-to: 6.5 6.5 6.2 5.15
Fixes: QTBUG-68884
Change-Id: I77091d7a2bc6e32d2aa292dc7650c1af091fcec1
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/opengl/qopengltexture.cpp')
-rw-r--r-- | src/opengl/qopengltexture.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/opengl/qopengltexture.cpp b/src/opengl/qopengltexture.cpp index f7053be6dd..3b8e14490b 100644 --- a/src/opengl/qopengltexture.cpp +++ b/src/opengl/qopengltexture.cpp @@ -3631,6 +3631,12 @@ void QOpenGLTexture::setData(const QImage& image, MipMapGeneration genMipMaps) return; } + QImage glImage = image.convertToFormat(QImage::Format_RGBA8888); + if (glImage.isNull()) { + qWarning("QOpenGLTexture::setData() failed to convert image"); + return; + } + if (context->isOpenGLES() && context->format().majorVersion() < 3) setFormat(QOpenGLTexture::RGBAFormat); else @@ -3641,7 +3647,6 @@ void QOpenGLTexture::setData(const QImage& image, MipMapGeneration genMipMaps) allocateStorage(QOpenGLTexture::RGBA, QOpenGLTexture::UInt8); // Upload pixel data and generate mipmaps - QImage glImage = image.convertToFormat(QImage::Format_RGBA8888); QOpenGLPixelTransferOptions uploadOptions; uploadOptions.setAlignment(1); setData(0, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, glImage.constBits(), &uploadOptions); |