From 5b1a0a5564a69331d581bcf4f94da0e11d14a31f Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 2 Jun 2011 11:07:21 +1000 Subject: Add private method for flushing the pixmap cache. Change-Id: I7330383b89a3a313dd845274d17d38c714db20ce Reviewed-by: Martin Jones --- src/declarative/util/qdeclarativepixmapcache.cpp | 14 ++++++++++++++ src/declarative/util/qdeclarativepixmapcache_p.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index a29854f..831aa75 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -584,6 +584,7 @@ public: void unreferencePixmap(QDeclarativePixmapData *); void referencePixmap(QDeclarativePixmapData *); + void flushCache(); protected: virtual void timerEvent(QTimerEvent *); @@ -682,6 +683,14 @@ void QDeclarativePixmapStore::timerEvent(QTimerEvent *) } } +/* + Remove all unreferenced pixmaps from the cache. +*/ +void QDeclarativePixmapStore::flushCache() +{ + shrinkCache(m_unreferencedCost); +} + QDeclarativePixmapReply::QDeclarativePixmapReply(QDeclarativePixmapData *d) : data(d), reader(0), requestSize(d->requestSize), loading(false), redirectCount(0) { @@ -1075,6 +1084,11 @@ bool QDeclarativePixmap::connectDownloadProgress(QObject *object, int method) return QMetaObject::connect(d->reply, QDeclarativePixmapReply::downloadProgressIndex, object, method); } +void QDeclarativePixmap::flushCache() +{ + pixmapStore()->flushCache(); +} + QT_END_NAMESPACE #include diff --git a/src/declarative/util/qdeclarativepixmapcache_p.h b/src/declarative/util/qdeclarativepixmapcache_p.h index 1cf76dd..48c9f8b 100644 --- a/src/declarative/util/qdeclarativepixmapcache_p.h +++ b/src/declarative/util/qdeclarativepixmapcache_p.h @@ -103,6 +103,8 @@ public: bool connectDownloadProgress(QObject *, const char *); bool connectDownloadProgress(QObject *, int); + static void flushCache(); + private: Q_DISABLE_COPY(QDeclarativePixmap) QDeclarativePixmapData *d; -- cgit v0.12