aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickpixmapcache.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-03-27 14:12:40 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-22 10:32:51 +0200
commit964dcdfb7bc106696b4be12b7f71ba52f8448973 (patch)
treeb8f593b885170ce2b601fb1e2cf78010408cec67 /src/quick/util/qquickpixmapcache.cpp
parentbcabdfbbe375a0e9872f9be6c9cbd212cebb5ee6 (diff)
Make profiling of pixmap cache events more consistent
Previously canceled replies weren't reported, the cache count was reported before it was updated, and the request or implicit sizes were reported instead of the size actually stored in memory. Task-number: QTBUG-37890 Change-Id: I9d9d9f6b9bfa75c7d56b778fc8174bda4e842d72 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/quick/util/qquickpixmapcache.cpp')
-rw-r--r--src/quick/util/qquickpixmapcache.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index a7f9174219..747c07b942 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -508,6 +508,7 @@ void QQuickPixmapReader::processJobs()
replies.remove(reply);
reply->close();
}
+ Q_QUICK_PROFILE(pixmapStateChanged<QQuickProfiler::PixmapLoadingError>(job->url));
// deleteLater, since not owned by this thread
job->deleteLater();
}
@@ -664,7 +665,11 @@ void QQuickPixmapReader::cancel(QQuickPixmapReply *reply)
// XXX
if (threadObject) threadObject->processJobs();
} else {
- jobs.removeAll(reply);
+ // If loading was started (reply removed from jobs) but the reply was never processed
+ // (otherwise it would have deleted itself) we need to profile an error.
+ if (jobs.removeAll(reply) == 0) {
+ Q_QUICK_PROFILE(pixmapStateChanged<QQuickProfiler::PixmapLoadingError>(reply->url));
+ }
delete reply;
}
mutex.unlock();
@@ -898,7 +903,9 @@ bool QQuickPixmapReply::event(QEvent *event)
data->textureFactory = de->textureFactory;
data->implicitSize = de->implicitSize;
Q_QUICK_PROFILE(pixmapLoadingFinished(data->url,
- data->requestSize.width() > 0 ? data->requestSize : data->implicitSize));
+ data->textureFactory != 0 && data->textureFactory->textureSize().isValid() ?
+ data->textureFactory->textureSize() :
+ (data->requestSize.isValid() ? data->requestSize : data->implicitSize)));
} else {
Q_QUICK_PROFILE(pixmapStateChanged<QQuickProfiler::PixmapLoadingError>(data->url));
data->errorString = de->errorString;
@@ -907,6 +914,8 @@ bool QQuickPixmapReply::event(QEvent *event)
data->reply = 0;
emit finished();
+ } else {
+ Q_QUICK_PROFILE(pixmapStateChanged<QQuickProfiler::PixmapLoadingError>(url));
}
delete this;
@@ -975,10 +984,10 @@ void QQuickPixmapData::removeFromCache()
{
if (inCache) {
QQuickPixmapKey key = { &url, &requestSize };
- Q_QUICK_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>(
- url, pixmapStore()->m_cache.count()));
pixmapStore()->m_cache.remove(key);
inCache = false;
+ Q_QUICK_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>(
+ url, pixmapStore()->m_cache.count()));
}
}
@@ -1242,8 +1251,7 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques
Q_QUICK_PROFILE(pixmapStateChanged<QQuickProfiler::PixmapLoadingStarted>(url));
d = createPixmapDataSync(this, engine, url, requestSize, &ok);
if (ok) {
- Q_QUICK_PROFILE(pixmapLoadingFinished(url,
- d->requestSize.width() > 0 ? d->requestSize : d->implicitSize));
+ Q_QUICK_PROFILE(pixmapLoadingFinished(url, QSize(width(), height())));
if (options & QQuickPixmap::Cache)
d->addToCache();
return;