xcb: Return standalone image from QXcbBackingStore::toImage()

Otherwise the original backingstore image will detach from the
m_xcb_image data on the next backingstore paint or scroll.

Pick-to: 6.2
Change-Id: I73f68d9c2e7c106951541831a5df8b97695f2001
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Tor Arne Vestbø 2021-11-17 12:48:59 +01:00
parent 185c8d5adf
commit db780c4ca5

View File

@ -850,7 +850,13 @@ QImage QXcbBackingStore::toImage() const
return QImage();
m_image->flushScrolledRegion(true);
return *m_image->image();
QImage image = *m_image->image();
// Return an image that does not share QImageData with the original image,
// even if they both point to the same data of the m_xcb_image, otherwise
// painting to m_qimage would detach it from the m_xcb_image data.
return QImage(image.constBits(), image.width(), image.height(), image.format());
}
QPlatformGraphicsBuffer *QXcbBackingStore::graphicsBuffer() const