make sure the rects cache file is always valid

BUG:177463

svn path=/trunk/KDE/kdelibs/; revision=895593
This commit is contained in:
Aaron J. Seigo 2008-12-11 06:24:25 +00:00
parent 47866f417b
commit e317155238

View File

@ -99,6 +99,7 @@ public:
QString findInTheme(const QString &image, const QString &theme) const;
void compositingChanged();
void discardCache();
void discardCache(bool recreateElementsCache);
bool useCache();
static const char *defaultTheme;
@ -173,19 +174,24 @@ void ThemePrivate::compositingChanged()
if (compositingActive != nowCompositingActive) {
compositingActive = nowCompositingActive;
discardCache();
discardCache(true);
emit q->themeChanged();
}
#endif
}
void ThemePrivate::discardCache()
{
discardCache(true);
}
void ThemePrivate::discardCache(bool recreateElementsCache)
{
delete pixmapCache;
pixmapCache = 0;
invalidElements.clear();
KPixmapCache::deleteCache("plasma_theme_" + themeName);
svgElementsCache = 0;
QString svgElementsFile = KStandardDirs::locateLocal("cache", "plasma-svgelements-" + themeName);
@ -193,6 +199,10 @@ void ThemePrivate::discardCache()
QFile f(svgElementsFile);
f.remove();
}
if (recreateElementsCache) {
svgElementsCache = KSharedConfig::openConfig(svgElementsFile);
}
}
class ThemeSingleton
@ -290,7 +300,7 @@ void Theme::setThemeName(const QString &themeName)
//discard the old theme cache
if (!d->themeName.isEmpty() && d->pixmapCache) {
d->discardCache();
d->discardCache(false);
}
d->themeName = theme;
@ -353,7 +363,7 @@ void Theme::setThemeName(const QString &themeName)
QFileInfo info(f);
if (d->useCache() && info.lastModified().toTime_t() > d->pixmapCache->timestamp()) {
d->discardCache();
d->discardCache(false);
}
d->invalidElements.clear();