From db780c4ca529a0d8d6896a08e0dc59c33b703adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 17 Nov 2021 12:48:59 +0100 Subject: [PATCH] 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 --- src/plugins/platforms/xcb/qxcbbackingstore.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 796ca24265..94edd87eb7 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -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