[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: icon cache is not updated properly
From:       Michael Pyne <mpyne () kde ! org>
Date:       2014-02-25 3:33:39
Message-ID: 2832603.kt5TlsBLQb () midna
[Download RAW message or body]

On Mon, February 24, 2014 10:50:15 Jan Grulich wrote:
> Hi,
> 
> in the upcoming version of plasma-nm we have a new icon set, it's a svgz
> file with some new icons and some of them are only different, but with same
> names. There is some problem when you install this new svgz file to the
> default directory with Plasma themes. I don't know why, but the new icons
> are not properly loaded (even if you restart plasma-desktop) and you have
> to remove Plasma icon cache manually to reload them properly, otherwise you
> have plasma-nm without some icons or with deformed icons. Do you have any
> idea what could be wrong? Or at least point me to the code where I can take
> a look? I wanted to fill a bug report, but I don't even know what component
> and product I should use. I think one solution could be rename this file to
> plasma-networkmanagement2.svgz, then it will be probably loaded properly,
> but I don't know if it is a good solution and the problem should be fixed
> anyway.

The problem is a mixture of those "famous 2 problems of Computer Science" 
(viz., naming things, cache invalidation, and off-by-one errors).

In this case the elements of the SVG theme are cached for performance purposes 
after the SVG is rendered to a pixmap. Every pixmap is matched to an icon 
name.

If you then change the source SVGZ for a given icon name, there's no way for 
the cache to know (since the way you tell the cache about different icons is 
by giving them different names), and it's not very easy for Plasma::Theme to 
know either (certainly we don't want it trying to checksum every single file 
in the icon theme every time a theme is loaded, it would be a horrible 
performance hit).

There is a way for the Plasma::Theme to version the entire theme (without 
having to rename the theme, that is). That versioning can be used with 
KSharedDataCache (in case that's what Plasma::Theme is using), by using the 
"timestamp" property of the shared data cache. See \
http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKSharedDataCache.html#aeaa4c736c28affcd97dc7a8bdc2193be


In this case you could examine the mtime of the theme metadata and if it's 
newer than the timestamp recorded in the cache, you'd delete the cache and let 
it refresh itself over time. I believe the Plasma code for it's theme is in 
kdelibs/plasma if you want to check.

But even this only works if you have a single file that is guaranteed to be 
modified if you change an icon in the theme (and, I thought Plasma::Theme was 
already doing this :).

In the event you want to just "sneak a change" to a single installed icon 
without affecting the rest of the theme, then the easiest proper solution 
probably actually *is* to delete the icon cache (which is equivalent with 
KSharedDataCache::deleteCache, and on purpose).

It's either that or running some kind of daemon/file-alteration monitor to 
track changes to the icon files and then call into KSharedDataCache to remove 
the specific entry that gets invalidated (and even that only would work if 
you're willing to link to kdelibs or KF5's kcoreaddons).

But there's never any harm with *unlinking* a cache file (you should never 
shred or overwrite it!), at least for the icon cache or other uses of 
KSharedDataCache.

Regards,
 - Michael Pyne

> > Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic