From 55d6c78c9abbb2a74b48167ebdbb2004f84cde50 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Wed, 14 Aug 2013 14:07:19 +0200 Subject: [PATCH] forward port of patch from master to fix crash due to non-existing theme --- src/plasma/private/theme_p.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp index cf8f33f26..a66d9fd60 100644 --- a/src/plasma/private/theme_p.cpp +++ b/src/plasma/private/theme_p.cpp @@ -125,18 +125,22 @@ bool ThemePrivate::useCache() cacheSize = config.themeCacheKb(); } const bool isRegularTheme = themeName != systemColorsTheme; - QString cacheFile = "plasma_theme_" + themeName; + const QString cacheFile = "plasma_theme_" + themeName; if (isRegularTheme) { + const QString cacheFileBase = cacheFile + "*.kcache"; + const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "desktoptheme/" + themeName + "/metadata.desktop"); - const KPluginInfo pluginInfo(path); + QString currentCacheFileName; + if (!path.isEmpty()) { + const KPluginInfo pluginInfo(path); + currentCacheFileName = cacheFile + "_v" + pluginInfo.version() + ".kcache"; + } // now we check for, and remove if necessary, old caches - const QString cacheFileBase = cacheFile + "*.kcache"; - cacheFile += "_v" + pluginInfo.version(); - const QString currentCacheFileName = cacheFile + ".kcache"; foreach (const QString &file, QStandardPaths::locateAll(QStandardPaths::CacheLocation, cacheFileBase)) { - if (!file.endsWith(currentCacheFileName)) { + if (currentCacheFileName.isEmpty() || + !file.endsWith(currentCacheFileName)) { QFile::remove(file); } }