Fix checking whether GraphicsBufferView is null

If the graphics buffer view is null, GraphicsBufferView::image() will
point to a valid memory location but the QImage at that address is going
to be null.
This commit is contained in:
Vlad Zahorodnii 2024-07-30 15:51:59 +03:00
parent b1ac04179d
commit bc2c5bf43e
3 changed files with 6 additions and 6 deletions

View file

@ -66,7 +66,7 @@ void BasicEGLSurfaceTextureWayland::update(const QRegion &region)
bool BasicEGLSurfaceTextureWayland::loadShmTexture(GraphicsBuffer *buffer)
{
const GraphicsBufferView view(buffer);
if (Q_UNLIKELY(!view.image())) {
if (Q_UNLIKELY(view.isNull())) {
return false;
}
@ -95,7 +95,7 @@ void BasicEGLSurfaceTextureWayland::updateShmTexture(GraphicsBuffer *buffer, con
}
const GraphicsBufferView view(buffer);
if (Q_UNLIKELY(!view.image())) {
if (Q_UNLIKELY(view.isNull())) {
return;
}

View file

@ -21,7 +21,7 @@ QPainterSurfaceTextureWayland::QPainterSurfaceTextureWayland(QPainterBackend *ba
bool QPainterSurfaceTextureWayland::create()
{
const GraphicsBufferView view(m_pixmap->buffer());
if (Q_LIKELY(view.image())) {
if (Q_LIKELY(!view.isNull())) {
// The buffer data is copied as the buffer interface returns a QImage
// which doesn't own the data of the underlying wl_shm_buffer object.
m_image = view.image()->copy();
@ -32,7 +32,7 @@ bool QPainterSurfaceTextureWayland::create()
void QPainterSurfaceTextureWayland::update(const QRegion &region)
{
const GraphicsBufferView view(m_pixmap->buffer());
if (Q_UNLIKELY(!view.image())) {
if (Q_UNLIKELY(view.isNull())) {
return;
}

View file

@ -214,8 +214,8 @@ static QImage shadowTileForBuffer(GraphicsBuffer *buffer)
{
if (buffer) {
const GraphicsBufferView view(buffer);
if (const QImage *image = view.image()) {
return image->copy();
if (!view.isNull()) {
return view.image()->copy();
}
}
return QImage();