protect usage of svg element cache config
this needs to be thoroughly checked over and tested before backporting; seems this fixes some occassional crashes users are running into. CCMAIL:notmart@gmail.com
This commit is contained in:
parent
74b55d7ca5
commit
d83bb2a72c
31
theme.cpp
31
theme.cpp
@ -223,7 +223,7 @@ bool ThemePrivate::useCache()
|
|||||||
// application is not running.
|
// application is not running.
|
||||||
QFile f(KStandardDirs::locate("data", "desktoptheme/" + themeName + "/metadata.desktop"));
|
QFile f(KStandardDirs::locate("data", "desktoptheme/" + themeName + "/metadata.desktop"));
|
||||||
QFileInfo info(f);
|
QFileInfo info(f);
|
||||||
if (info.lastModified().toTime_t() > pixmapCache->lastModifiedTime()) {
|
if (info.lastModified().toTime_t() > uint(pixmapCache->lastModifiedTime())) {
|
||||||
pixmapCache->clear();
|
pixmapCache->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,6 +280,8 @@ void ThemePrivate::compositingChanged()
|
|||||||
void ThemePrivate::discardCache(CacheTypes caches)
|
void ThemePrivate::discardCache(CacheTypes caches)
|
||||||
{
|
{
|
||||||
if (caches & PixmapCache) {
|
if (caches & PixmapCache) {
|
||||||
|
pixmapsToCache.clear();
|
||||||
|
saveTimer->stop();
|
||||||
if (pixmapCache) {
|
if (pixmapCache) {
|
||||||
pixmapCache->clear();
|
pixmapCache->clear();
|
||||||
}
|
}
|
||||||
@ -288,12 +290,12 @@ void ThemePrivate::discardCache(CacheTypes caches)
|
|||||||
delete pixmapCache;
|
delete pixmapCache;
|
||||||
pixmapCache = 0;
|
pixmapCache = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cachedStyleSheets.clear();
|
cachedStyleSheets.clear();
|
||||||
invalidElements.clear();
|
|
||||||
pixmapsToCache.clear();
|
|
||||||
saveTimer->stop();
|
|
||||||
|
|
||||||
if (caches & SvgElementsCache) {
|
if (caches & SvgElementsCache) {
|
||||||
|
invalidElements.clear();
|
||||||
|
|
||||||
if (svgElementsCache) {
|
if (svgElementsCache) {
|
||||||
QFile f(svgElementsCache->name());
|
QFile f(svgElementsCache->name());
|
||||||
svgElementsCache = 0;
|
svgElementsCache = 0;
|
||||||
@ -465,13 +467,16 @@ Theme::Theme(const QString &themeName, QObject *parent)
|
|||||||
|
|
||||||
Theme::~Theme()
|
Theme::~Theme()
|
||||||
{
|
{
|
||||||
|
if (d->svgElementsCache) {
|
||||||
QHashIterator<QString, QSet<QString> > it(d->invalidElements);
|
QHashIterator<QString, QSet<QString> > it(d->invalidElements);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
KConfigGroup imageGroup(d->svgElementsCache, it.key());
|
KConfigGroup imageGroup(d->svgElementsCache, it.key());
|
||||||
imageGroup.writeEntry("invalidElements", it.value().toList()); //FIXME: add QSet support to KConfig
|
imageGroup.writeEntry("invalidElements", it.value().toList()); //FIXME: add QSet support to KConfig
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
d->onAppExitCleanup();
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,7 +670,6 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
|||||||
|
|
||||||
discardCache(SvgElementsCache);
|
discardCache(SvgElementsCache);
|
||||||
|
|
||||||
invalidElements.clear();
|
|
||||||
emit q->themeChanged();
|
emit q->themeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -923,7 +927,7 @@ bool Theme::findInCache(const QString &key, QPixmap &pix)
|
|||||||
// BIC FIXME: Should be merged with the other findInCache method above when we break BC
|
// BIC FIXME: Should be merged with the other findInCache method above when we break BC
|
||||||
bool Theme::findInCache(const QString &key, QPixmap &pix, unsigned int lastModified)
|
bool Theme::findInCache(const QString &key, QPixmap &pix, unsigned int lastModified)
|
||||||
{
|
{
|
||||||
if (d->useCache() && lastModified > d->pixmapCache->lastModifiedTime()) {
|
if (d->useCache() && lastModified > uint(d->pixmapCache->lastModifiedTime())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -954,7 +958,7 @@ void Theme::insertIntoCache(const QString& key, const QPixmap& pix, const QStrin
|
|||||||
|
|
||||||
bool Theme::findInRectsCache(const QString &image, const QString &element, QRectF &rect) const
|
bool Theme::findInRectsCache(const QString &image, const QString &element, QRectF &rect) const
|
||||||
{
|
{
|
||||||
if (!d->pixmapCache) {
|
if (!d->svgElementsCache) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -987,6 +991,10 @@ bool Theme::findInRectsCache(const QString &image, const QString &element, QRect
|
|||||||
|
|
||||||
QStringList Theme::listCachedRectKeys(const QString &image) const
|
QStringList Theme::listCachedRectKeys(const QString &image) const
|
||||||
{
|
{
|
||||||
|
if (!d->svgElementsCache) {
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
|
||||||
KConfigGroup imageGroup(d->svgElementsCache, image);
|
KConfigGroup imageGroup(d->svgElementsCache, image);
|
||||||
QStringList keys = imageGroup.keyList();
|
QStringList keys = imageGroup.keyList();
|
||||||
|
|
||||||
@ -1006,7 +1014,7 @@ QStringList Theme::listCachedRectKeys(const QString &image) const
|
|||||||
|
|
||||||
void Theme::insertIntoRectsCache(const QString& image, const QString &element, const QRectF &rect)
|
void Theme::insertIntoRectsCache(const QString& image, const QString &element, const QRectF &rect)
|
||||||
{
|
{
|
||||||
if (!d->pixmapCache) {
|
if (!d->svgElementsCache) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1029,18 +1037,23 @@ void Theme::insertIntoRectsCache(const QString& image, const QString &element, c
|
|||||||
|
|
||||||
void Theme::invalidateRectsCache(const QString& image)
|
void Theme::invalidateRectsCache(const QString& image)
|
||||||
{
|
{
|
||||||
|
if (d->svgElementsCache) {
|
||||||
KConfigGroup imageGroup(d->svgElementsCache, image);
|
KConfigGroup imageGroup(d->svgElementsCache, image);
|
||||||
imageGroup.deleteGroup();
|
imageGroup.deleteGroup();
|
||||||
|
}
|
||||||
|
|
||||||
releaseRectsCache(image);
|
d->invalidElements.remove(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Theme::releaseRectsCache(const QString &image)
|
void Theme::releaseRectsCache(const QString &image)
|
||||||
{
|
{
|
||||||
QHash<QString, QSet<QString> >::iterator it = d->invalidElements.find(image);
|
QHash<QString, QSet<QString> >::iterator it = d->invalidElements.find(image);
|
||||||
if (it != d->invalidElements.end()) {
|
if (it != d->invalidElements.end()) {
|
||||||
|
if (!d->svgElementsCache) {
|
||||||
KConfigGroup imageGroup(d->svgElementsCache, it.key());
|
KConfigGroup imageGroup(d->svgElementsCache, it.key());
|
||||||
imageGroup.writeEntry("invalidElements", it.value().toList());
|
imageGroup.writeEntry("invalidElements", it.value().toList());
|
||||||
|
}
|
||||||
|
|
||||||
d->invalidElements.erase(it);
|
d->invalidElements.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user