aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-07-20 16:54:00 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-07-23 09:28:01 +0000
commit040f7b93b44b5b7880a8e07f878158440fcb2f31 (patch)
treecf1763ad7dc72ae7d687219641cab3fe888ffbda
parent556cd479823a0d0e88e5fa1a18368d23eb8f87f5 (diff)
Update QQuickImage's DPR if re-loading the image didn't
An SVG doesn't have a DPR, but we need to reload and repaint it anyway when the DPR of the screen changes. So store the DPR of the item explicitly if reloading it didn't change the value (for instance, because sourceSize was not set). Otherwise, DPR changes are only handled when moving from a 1.0 (the default) DPR display to a different display, but not when moving back. Fixes: QTBUG-94622 Change-Id: I9f0a847699ab027ef876e341b8c6a954a6167ab3 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit 08838f434b55024d9d5a9252fc2a3fb782b087da) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quick/items/qquickimagebase.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/quick/items/qquickimagebase.cpp b/src/quick/items/qquickimagebase.cpp
index 1cf9d88795..2ad3683478 100644
--- a/src/quick/items/qquickimagebase.cpp
+++ b/src/quick/items/qquickimagebase.cpp
@@ -56,8 +56,8 @@ QT_BEGIN_NAMESPACE
bool QQuickImageBasePrivate::updateDevicePixelRatio(qreal targetDevicePixelRatio)
{
// QQuickImageProvider and SVG and PDF can generate a high resolution image when
- // sourceSize is set (this function is only called if it's set).
- // If sourceSize is not set then the provider default size will be used, as usual.
+ // sourceSize is set. If sourceSize is not set then the provider default size will
+ // be used, as usual.
bool setDevicePixelRatio = false;
if (url.scheme() == QLatin1String("image")) {
setDevicePixelRatio = true;
@@ -418,10 +418,14 @@ void QQuickImageBase::itemChange(ItemChange change, const ItemChangeData &value)
Q_D(QQuickImageBase);
// If the screen DPI changed, reload image.
if (change == ItemDevicePixelRatioHasChanged && value.realValue != d->devicePixelRatio) {
+ const auto oldDpr = d->devicePixelRatio;
// ### how can we get here with !qmlEngine(this)? that implies
// itemChange() on an item pending deletion, which seems strange.
if (qmlEngine(this) && isComponentComplete() && d->url.isValid()) {
load();
+ // not changed when loading (sourceSize might not be set)
+ if (d->devicePixelRatio == oldDpr)
+ d->updateDevicePixelRatio(value.realValue);
}
}
QQuickItem::itemChange(change, value);