aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickpixmapcache.cpp
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals@canonical.com>2017-01-09 15:22:22 +0100
committerRobin Burchell <robin.burchell@crimson.no>2017-01-27 18:11:30 +0000
commitd0649a1b457f321cfafee1aaf443543fd11a7112 (patch)
tree08beaa9b918087163ce68da34e8547bc99985490 /src/quick/util/qquickpixmapcache.cpp
parent68932f24c66e2589bc202f4b5b7c248b7d19e6be (diff)
Make Item::grabToImage work in more cases, and improve test coverage
This fixes a regression caused by 9c50216c7bbbdb2bb51d4485286bf09e12fb5b62 when the Image specified fillMode: aspectRatioCrop/Fit. [ChangeLog][QtQuick][Image] Item::grabToImage on an Image element will now work regardless of the Image's sourceSize or cache properties. Change-Id: I225854c48f0c35a3cb2ef0dd56bf51bd88c31779 Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
Diffstat (limited to 'src/quick/util/qquickpixmapcache.cpp')
-rw-r--r--src/quick/util/qquickpixmapcache.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index 1c6b2afb54..be6d4d18bd 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -84,6 +84,7 @@
QT_BEGIN_NAMESPACE
+const QLatin1String QQuickPixmap::itemGrabberScheme = QLatin1String("itemgrabber");
#ifndef QT_NO_DEBUG
static const bool qsg_leak_check = !qEnvironmentVariableIsEmpty("QML_LEAK_CHECK");
@@ -1462,8 +1463,15 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques
QHash<QQuickPixmapKey, QQuickPixmapData *>::Iterator iter = store->m_cache.end();
// If Cache is disabled, the pixmap will always be loaded, even if there is an existing
- // cached version.
- if (options & QQuickPixmap::Cache)
+ // cached version. Unless it's an itemgrabber url, since the cache is used to pass
+ // the result between QQuickItemGrabResult and QQuickImage.
+ if (url.scheme() == itemGrabberScheme) {
+ QSize dummy;
+ if (requestSize != dummy)
+ qWarning() << "Ignoring sourceSize request for image url that came from grabToImage. Use the targetSize parameter of the grabToImage() function instead.";
+ const QQuickPixmapKey grabberKey = { &url, &dummy, QQuickImageProviderOptions() };
+ iter = store->m_cache.find(grabberKey);
+ } else if (options & QQuickPixmap::Cache)
iter = store->m_cache.find(key);
if (iter == store->m_cache.end()) {