summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/image/qpixmap.cpp1
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp14
2 files changed, 15 insertions, 0 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index df05bcc76d..4bfdbd9253 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -899,6 +899,7 @@ void QPixmap::fill(const QColor &color)
// it will be filled with new pixel data anyway.
QPlatformPixmap *d = data->createCompatiblePlatformPixmap();
d->resize(data->width(), data->height());
+ d->setDevicePixelRatio(data->devicePixelRatio());
data = d;
}
data->fill(color);
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index a70305bb14..6c6c282af4 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -121,6 +121,7 @@ private slots:
void copy();
void move();
void deepCopyPreservesDpr();
+ void fillPreservesDpr();
void dprPassthrough();
void depthOfNullObjects();
@@ -1172,6 +1173,19 @@ void tst_QPixmap::deepCopyPreservesDpr()
QCOMPARE(dest.devicePixelRatio(), dpr);
}
+// Check that the DPR is preserved after doing a fill after an
+// assigned copy of the QPixmap
+void tst_QPixmap::fillPreservesDpr()
+{
+ const qreal dpr = 2;
+ QPixmap src(32, 32);
+ src.setDevicePixelRatio(dpr);
+ src.fill(Qt::red);
+ QPixmap dest = src;
+ dest.fill(Qt::blue);
+ QCOMPARE(dest.devicePixelRatio(), dpr);
+}
+
void tst_QPixmap::dprPassthrough()
{
const qreal dpr = 2;