simplify the discardCache call; makes sanitizing this code easier (e.g. never having a null pointer!)
svn path=/trunk/KDE/kdelibs/; revision=1015481
This commit is contained in:
parent
e2ab114d6d
commit
c4079787fa
24
theme.cpp
24
theme.cpp
@ -125,7 +125,7 @@ public:
|
|||||||
|
|
||||||
QString findInTheme(const QString &image, const QString &theme) const;
|
QString findInTheme(const QString &image, const QString &theme) const;
|
||||||
void compositingChanged();
|
void compositingChanged();
|
||||||
void discardCache(bool recreateElementsCache);
|
void discardCache();
|
||||||
void scheduledCacheUpdate();
|
void scheduledCacheUpdate();
|
||||||
void colorsChanged();
|
void colorsChanged();
|
||||||
bool useCache();
|
bool useCache();
|
||||||
@ -212,13 +212,13 @@ void ThemePrivate::compositingChanged()
|
|||||||
|
|
||||||
if (compositingActive != nowCompositingActive) {
|
if (compositingActive != nowCompositingActive) {
|
||||||
compositingActive = nowCompositingActive;
|
compositingActive = nowCompositingActive;
|
||||||
discardCache(true);
|
discardCache();
|
||||||
emit q->themeChanged();
|
emit q->themeChanged();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemePrivate::discardCache(bool recreateElementsCache)
|
void ThemePrivate::discardCache()
|
||||||
{
|
{
|
||||||
KPixmapCache::deleteCache("plasma_theme_" + themeName);
|
KPixmapCache::deleteCache("plasma_theme_" + themeName);
|
||||||
delete pixmapCache;
|
delete pixmapCache;
|
||||||
@ -227,16 +227,13 @@ void ThemePrivate::discardCache(bool recreateElementsCache)
|
|||||||
pixmapsToCache.clear();
|
pixmapsToCache.clear();
|
||||||
saveTimer->stop();
|
saveTimer->stop();
|
||||||
|
|
||||||
svgElementsCache = 0;
|
|
||||||
const QString svgElementsFile = KStandardDirs::locateLocal("cache", "plasma-svgelements-" + themeName);
|
const QString svgElementsFile = KStandardDirs::locateLocal("cache", "plasma-svgelements-" + themeName);
|
||||||
if (!svgElementsFile.isEmpty()) {
|
if (!svgElementsFile.isEmpty()) {
|
||||||
QFile f(svgElementsFile);
|
QFile f(svgElementsFile);
|
||||||
f.remove();
|
f.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recreateElementsCache) {
|
svgElementsCache = KSharedConfig::openConfig(svgElementsFile);
|
||||||
svgElementsCache = KSharedConfig::openConfig(svgElementsFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemePrivate::scheduledCacheUpdate()
|
void ThemePrivate::scheduledCacheUpdate()
|
||||||
@ -254,7 +251,7 @@ void ThemePrivate::scheduledCacheUpdate()
|
|||||||
|
|
||||||
void ThemePrivate::colorsChanged()
|
void ThemePrivate::colorsChanged()
|
||||||
{
|
{
|
||||||
discardCache(true);
|
discardCache();
|
||||||
colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, colors);
|
colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, colors);
|
||||||
buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, colors);
|
buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, colors);
|
||||||
viewColorScheme = KColorScheme(QPalette::Active, KColorScheme::View, colors);
|
viewColorScheme = KColorScheme(QPalette::Active, KColorScheme::View, colors);
|
||||||
@ -379,7 +376,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
|||||||
|
|
||||||
//discard the old theme cache
|
//discard the old theme cache
|
||||||
if (!themeName.isEmpty() && pixmapCache) {
|
if (!themeName.isEmpty() && pixmapCache) {
|
||||||
discardCache(false);
|
discardCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
themeName = theme;
|
themeName = theme;
|
||||||
@ -462,14 +459,15 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
|||||||
QFile f(metadataPath);
|
QFile f(metadataPath);
|
||||||
QFileInfo info(f);
|
QFileInfo info(f);
|
||||||
|
|
||||||
|
|
||||||
if (useCache() && info.lastModified().toTime_t() > pixmapCache->timestamp()) {
|
if (useCache() && info.lastModified().toTime_t() > pixmapCache->timestamp()) {
|
||||||
discardCache(false);
|
discardCache();
|
||||||
|
} else {
|
||||||
|
QString svgElementsFile = KStandardDirs::locateLocal("cache", "plasma-svgelements-" + themeName);
|
||||||
|
svgElementsCache = KSharedConfig::openConfig(svgElementsFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidElements.clear();
|
invalidElements.clear();
|
||||||
QString svgElementsFile = KStandardDirs::locateLocal("cache", "plasma-svgelements-" + themeName);
|
|
||||||
svgElementsCache = KSharedConfig::openConfig(svgElementsFile);
|
|
||||||
|
|
||||||
emit q->themeChanged();
|
emit q->themeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user