summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Ehrlicher <[email protected]>2025-06-20 17:55:27 +0200
committerChristian Ehrlicher <[email protected]>2025-06-25 03:27:53 +0200
commit7d1e46509865f5e9dbf8190ef6b21aeb3b311c1b (patch)
tree76aad12e0195162bf90f355be02e3e166dc0514e
parent3e6805b55467b7fcb299add3e381a53e2c42b7f3 (diff)
QIcon: round calculated devicePixelRatio to a useful value
Round the calculated devicePixelRatio to 2 decimals to avoid that the dpr differs for less than 0.1 percent and force a pixmap detach. Pick-to: 6.10 6.9 Change-Id: I51251f2ced9e6e3c3d0c1e80d81b32a573152885 Reviewed-by: Volker Hilsheimer <[email protected]> Reviewed-by: Axel Spoerl <[email protected]>
-rw-r--r--src/gui/image/qicon.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 1c4b2f205b7..8fa996c8689 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -144,7 +144,7 @@ void QIconPrivate::clearIconCache()
/*! \internal
Computes the displayDevicePixelRatio for a pixmap.
- If displayDevicePixelRatio is 1.0 the reurned value is 1.0, always.
+ If displayDevicePixelRatio is 1.0 the returned value is 1.0, always.
For a displayDevicePixelRatio of 2.0 the returned value will be between
1.0 and 2.0, depending on requestedSize and actualsize:
@@ -161,8 +161,9 @@ qreal QIconPrivate::pixmapDevicePixelRatio(qreal displayDevicePixelRatio, const
return displayDevicePixelRatio;
}
qreal scale = 0.5 * (qreal(actualSize.width()) / qreal(targetSize.width()) +
- qreal(actualSize.height() / qreal(targetSize.height())));
- return qMax(qreal(1.0), displayDevicePixelRatio *scale);
+ qreal(actualSize.height()) / qreal(targetSize.height()));
+ qreal dpr = qMax(qreal(1.0), displayDevicePixelRatio * scale);
+ return qRound(dpr * 100) / 100.0;
}
QPixmapIconEngine::QPixmapIconEngine()