diff options
-rw-r--r-- | src/gui/image/qpixmap_raster.cpp | 2 | ||||
-rw-r--r-- | tests/auto/gui/image/qpixmap/tst_qpixmap.cpp | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 54a5b94840..7eb61adb2d 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -349,8 +349,6 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage sourceImage, Qt::ImageCo } is_null = (w <= 0 || h <= 0); - if (image.d) - image.d->devicePixelRatio = sourceImage.devicePixelRatio(); //ensure the pixmap and the image resulting from toImage() have the same cacheKey(); setSerialNumber(image.cacheKey() >> 32); if (image.d) diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index 72609d4095..e3bda6c2df 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -119,6 +119,7 @@ private slots: void refUnref(); void copy(); + void deepCopyPreservesDpr(); void depthOfNullObjects(); void transformed(); @@ -1133,6 +1134,19 @@ void tst_QPixmap::copy() QCOMPARE(trans, transCopy); } +// QTBUG-58653: Force a deep copy of a pixmap by +// having a QPainter and check whether DevicePixelRatio is preserved +void tst_QPixmap::deepCopyPreservesDpr() +{ + const qreal dpr = 2; + QPixmap src(32, 32); + src.setDevicePixelRatio(dpr); + src.fill(Qt::red); + QPainter painter(&src); + const QPixmap dest = src.copy(); + QCOMPARE(dest.devicePixelRatio(), dpr); +} + void tst_QPixmap::depthOfNullObjects() { QBitmap b1; |