Skip to content

Commit

Permalink
Add QImage null check when QOpenGLTexture converts
Browse files Browse the repository at this point in the history
...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 <[email protected]>
  • Loading branch information
alpqr committed Mar 21, 2023
1 parent c0182c7 commit a561d52
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/opengl/qopengltexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit a561d52

Please sign in to comment.