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>
This commit is contained in:
Laszlo Agocs 2023-03-17 15:03:54 +01:00
parent c0182c7817
commit a561d52a83

View File

@ -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);