diff --git a/theme.cpp b/theme.cpp index f83eb98f4..7404e10fb 100644 --- a/theme.cpp +++ b/theme.cpp @@ -65,6 +65,7 @@ public: useGlobal(true), hasWallpapers(false) { + pixmapCache.setCacheLimit(0); generalFont = QApplication::font(); } @@ -531,6 +532,11 @@ void Theme::invalidateRectsCache(const QString& image) imageGroup.deleteGroup(); } +void Theme::setCacheLimit(int kbytes) +{ + d->pixmapCache.setCacheLimit(kbytes); +} + } #include diff --git a/theme.h b/theme.h index 0f0749590..74e23ce42 100644 --- a/theme.h +++ b/theme.h @@ -192,6 +192,16 @@ class PLASMA_EXPORT Theme : public QObject **/ void insertIntoCache(const QString& key, const QPixmap& pix); + /** + * Sets the maximum size of the cache (in kilobytes). If cache gets bigger + * the limit then some entries are removed + * Setting cache limit to 0 disables automatic cache size limiting. + * + * Note that the cleanup might not be done immediately, so the cache might + * temporarily (for a few seconds) grow bigger than the limit. + **/ + void setCacheLimit(int kbytes); + bool findInRectsCache(const QString &image, const QString &element, QRectF &rect) const; void insertIntoRectsCache(const QString& image, const QString &element, const QRectF &rect); void invalidateRectsCache(const QString& image);