summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2023-03-17 15:03:54 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-03-21 14:20:02 +0000
commit44926b9a0ffaa358caf5a5cfbf070756c3e3ad22 (patch)
tree04d0d02a3a7ecaa39dba4e6c15b908f3cfbabfa0 /src
parenta86a06ef6389381b844a3fe7288a21e6fda9fe95 (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(). Fixes: QTBUG-68884 Change-Id: I77091d7a2bc6e32d2aa292dc7650c1af091fcec1 Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit a561d52a8352f17f4a39bf54e0d3d9842c0d4064) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/opengl/qopengltexture.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/opengl/qopengltexture.cpp b/src/opengl/qopengltexture.cpp
index 18a34aacf3..815df3300c 100644
--- a/src/opengl/qopengltexture.cpp
+++ b/src/opengl/qopengltexture.cpp
@@ -3672,6 +3672,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
@@ -3682,7 +3688,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);