schedule a rect cache sync when stuff gets in
do a disc sync with a 2 minutes delay
This commit is contained in:
parent
0b10a16113
commit
0596cf176f
@ -69,10 +69,16 @@ ThemePrivate::ThemePrivate(QObject *parent)
|
|||||||
ThemeConfig config;
|
ThemeConfig config;
|
||||||
cacheTheme = config.cacheTheme();
|
cacheTheme = config.cacheTheme();
|
||||||
|
|
||||||
saveTimer = new QTimer(this);
|
pixmapSaveTimer = new QTimer(this);
|
||||||
saveTimer->setSingleShot(true);
|
pixmapSaveTimer->setSingleShot(true);
|
||||||
saveTimer->setInterval(600);
|
pixmapSaveTimer->setInterval(600);
|
||||||
QObject::connect(saveTimer, SIGNAL(timeout()), this, SLOT(scheduledCacheUpdate()));
|
QObject::connect(pixmapSaveTimer, SIGNAL(timeout()), this, SLOT(scheduledCacheUpdate()));
|
||||||
|
|
||||||
|
rectSaveTimer = new QTimer(this);
|
||||||
|
rectSaveTimer->setSingleShot(true);
|
||||||
|
//2 minutes
|
||||||
|
rectSaveTimer->setInterval(2 * 60 * 1000);
|
||||||
|
QObject::connect(rectSaveTimer, SIGNAL(timeout()), this, SLOT(saveSvgElementsCache()));
|
||||||
|
|
||||||
updateNotificationTimer = new QTimer(this);
|
updateNotificationTimer = new QTimer(this);
|
||||||
updateNotificationTimer->setSingleShot(true);
|
updateNotificationTimer->setSingleShot(true);
|
||||||
@ -290,7 +296,7 @@ void ThemePrivate::discardCache(CacheTypes caches)
|
|||||||
{
|
{
|
||||||
if (caches & PixmapCache) {
|
if (caches & PixmapCache) {
|
||||||
pixmapsToCache.clear();
|
pixmapsToCache.clear();
|
||||||
saveTimer->stop();
|
pixmapSaveTimer->stop();
|
||||||
if (pixmapCache) {
|
if (pixmapCache) {
|
||||||
pixmapCache->clear();
|
pixmapCache->clear();
|
||||||
}
|
}
|
||||||
@ -465,6 +471,21 @@ void ThemePrivate::settingsChanged(bool emitChanges)
|
|||||||
setThemeName(cg.readEntry("name", ThemePrivate::defaultTheme), false, emitChanges);
|
setThemeName(cg.readEntry("name", ThemePrivate::defaultTheme), false, emitChanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThemePrivate::saveSvgElementsCache()
|
||||||
|
{
|
||||||
|
if (svgElementsCache) {
|
||||||
|
QHashIterator<QString, QSet<QString> > it(invalidElements);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
KConfigGroup imageGroup(svgElementsCache, it.key());
|
||||||
|
imageGroup.writeEntry("invalidElements", it.value().toList()); //FIXME: add QSet support to KConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
//Pretty drastic, but this is executed only very rarely
|
||||||
|
svgElementsCache->sync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QColor ThemePrivate::color(Theme::ColorRole role) const
|
QColor ThemePrivate::color(Theme::ColorRole role) const
|
||||||
{
|
{
|
||||||
switch (role) {
|
switch (role) {
|
||||||
|
@ -94,6 +94,7 @@ public Q_SLOTS:
|
|||||||
void onAppExitCleanup();
|
void onAppExitCleanup();
|
||||||
void notifyOfChanged();
|
void notifyOfChanged();
|
||||||
void settingsChanged(bool emitChanges);
|
void settingsChanged(bool emitChanges);
|
||||||
|
void saveSvgElementsCache();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void themeChanged();
|
void themeChanged();
|
||||||
@ -134,7 +135,8 @@ public:
|
|||||||
QHash<QString, QString> idsToCache;
|
QHash<QString, QString> idsToCache;
|
||||||
QHash<styles, QString> cachedStyleSheets;
|
QHash<styles, QString> cachedStyleSheets;
|
||||||
QHash<QString, QString> discoveries;
|
QHash<QString, QString> discoveries;
|
||||||
QTimer *saveTimer;
|
QTimer *pixmapSaveTimer;
|
||||||
|
QTimer *rectSaveTimer;
|
||||||
QTimer *updateNotificationTimer;
|
QTimer *updateNotificationTimer;
|
||||||
unsigned cacheSize;
|
unsigned cacheSize;
|
||||||
CacheTypes cachesToDiscard;
|
CacheTypes cachesToDiscard;
|
||||||
|
@ -91,17 +91,7 @@ Theme::Theme(const QString &themeName, QObject *parent)
|
|||||||
|
|
||||||
Theme::~Theme()
|
Theme::~Theme()
|
||||||
{
|
{
|
||||||
if (d->svgElementsCache) {
|
d->saveSvgElementsCache();
|
||||||
QHashIterator<QString, QSet<QString> > it(d->invalidElements);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
KConfigGroup imageGroup(d->svgElementsCache, it.key());
|
|
||||||
imageGroup.writeEntry("invalidElements", it.value().toList()); //FIXME: add QSet support to KConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
//The application is probably dying, last occasion to write to disk
|
|
||||||
d->svgElementsCache->sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (d == ThemePrivate::globalTheme) {
|
if (d == ThemePrivate::globalTheme) {
|
||||||
if (!ThemePrivate::globalThemeRefCount.deref()) {
|
if (!ThemePrivate::globalThemeRefCount.deref()) {
|
||||||
@ -346,8 +336,8 @@ void Theme::insertIntoCache(const QString &key, const QPixmap &pix, const QStrin
|
|||||||
d->keysToCache.insert(key, id);
|
d->keysToCache.insert(key, id);
|
||||||
d->idsToCache.insert(id, key);
|
d->idsToCache.insert(id, key);
|
||||||
|
|
||||||
//always start timer in d->saveTimer's thread
|
//always start timer in d->pixmapSaveTimer's thread
|
||||||
QMetaObject::invokeMethod(d->saveTimer, "start", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(d->pixmapSaveTimer, "start", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,6 +418,8 @@ void Theme::insertIntoRectsCache(const QString &image, const QString &element, c
|
|||||||
it.value().insert(element);
|
it.value().insert(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d->rectSaveTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Theme::invalidateRectsCache(const QString &image)
|
void Theme::invalidateRectsCache(const QString &image)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user