From 5ed6f6d546cd74dc9e98f429aca0e75b6490d794 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Thu, 4 Mar 2010 22:28:39 +0000 Subject: [PATCH] cleanup the pixmaps before app exit, otherwise they can leak into x svn path=/trunk/KDE/kdelibs/; revision=1099009 --- theme.cpp | 17 +++++++++++++++++ theme.h | 1 + 2 files changed, 18 insertions(+) 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