diff --git a/theme.cpp b/theme.cpp index cb8620088..cc5ee060c 100644 --- a/theme.cpp +++ b/theme.cpp @@ -128,6 +128,7 @@ public: bool useCache(); void settingsFileChanged(const QString &); void setThemeName(const QString &themeName, bool writeSettings); + void onAppExitCleanup(); static const char *defaultTheme; static const char *themeRcFile; @@ -181,6 +182,14 @@ bool ThemePrivate::useCache() return cacheTheme; } +void ThemePrivate::onAppExitCleanup() +{ + pixmapsToCache.clear(); + delete pixmapCache; + pixmapCache = 0; + cacheTheme = false; +} + QString ThemePrivate::findInTheme(const QString &image, const QString &theme) const { //TODO: this should be using Package @@ -284,6 +293,10 @@ Theme::Theme(QObject *parent) d(new ThemePrivate(this)) { settingsChanged(); + if (QCoreApplication::instance()) { + connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), + this, SLOT(onAppExitCleanup())); + } } Theme::Theme(const QString &themeName, QObject *parent) @@ -295,6 +308,10 @@ Theme::Theme(const QString &themeName, QObject *parent) d->cacheTheme = false; setThemeName(themeName); d->cacheTheme = useCache; + if (QCoreApplication::instance()) { + connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), + this, SLOT(onAppExitCleanup())); + } } Theme::~Theme() diff --git a/theme.h b/theme.h index a18ed145a..9464b0236 100644 --- a/theme.h +++ b/theme.h @@ -329,6 +329,7 @@ class PLASMA_EXPORT Theme : public QObject Q_PRIVATE_SLOT(d, void colorsChanged()) Q_PRIVATE_SLOT(d, void settingsFileChanged(const QString &)) Q_PRIVATE_SLOT(d, void scheduledCacheUpdate()) + Q_PRIVATE_SLOT(d, void onAppExitCleanup()) }; } // Plasma namespace