aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickimagebase.cpp
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@crimson.no>2017-04-27 15:39:36 +0200
committerRobin Burchell <robin.burchell@crimson.no>2017-04-28 12:18:20 +0000
commitb0cc12406ca853c0395f71436b3ef653eb383e97 (patch)
tree61a0a939a4aec11a2aac35e85200fced6517b9f6 /src/quick/items/qquickimagebase.cpp
parent4be29bdbd5fc5d9751ff07718dcf04c256d4bd34 (diff)
QQuickImageBase: Avoid a signal connection altogether
7568922fa240e6e9440e9c6e93bf8ec00c06ec17 already made this faster (by making it not string-based, and used when it was required). We can do one better after d870ea28656a2155c39a1aabefa1c56871a017e4, by avoiding the connection altogether, and explicitly only updating when the DPI changes. This doesn't affect qmlbench performance a great deal AFAICT (presumably because ItemSceneChange events don't just fall out of the sky); but it will help when they do happen, and it will also no longer allocate memory (for the connection). Change-Id: I043f6e22565554cee9ce6346fa7feefadfff0c7a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quick/items/qquickimagebase.cpp')
-rw-r--r--src/quick/items/qquickimagebase.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/quick/items/qquickimagebase.cpp b/src/quick/items/qquickimagebase.cpp
index 33d69f5032..75a93908b1 100644
--- a/src/quick/items/qquickimagebase.cpp
+++ b/src/quick/items/qquickimagebase.cpp
@@ -328,18 +328,18 @@ void QQuickImageBase::requestProgress(qint64 received, qint64 total)
void QQuickImageBase::itemChange(ItemChange change, const ItemChangeData &value)
{
- if (change == ItemSceneChange && value.window)
- connect(value.window, &QQuickWindow::screenChanged, this, &QQuickImageBase::handleScreenChanged);
+ Q_D(QQuickImageBase);
+ // If the screen DPI changed, reload image.
+ if (change == ItemDevicePixelRatioHasChanged && value.realValue != 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();
+ }
+ }
QQuickItem::itemChange(change, value);
}
-void QQuickImageBase::handleScreenChanged(QScreen* screen)
-{
- // Screen DPI might have changed, reload images on screen change.
- if (qmlEngine(this) && screen && isComponentComplete())
- load();
-}
-
void QQuickImageBase::componentComplete()
{
Q_D(QQuickImageBase);