[PATCH] KFileItem performance improvement

David Faure faure at kde.org
Fri Jun 27 09:55:06 BST 2008

On Thursday 26 June 2008, Peter Penz wrote:
> Attached is a patch which remembers the icon name after KFileItem::iconName() 
> is invoked at least once.

I think it's a good idea, but as with all caches, the main problem is when to invalidate
the cache. 1) if you rename foo.txt to foo.jpg the icon used to change, but doesn't change
anymore, right? Or 2) if you use the properties dialog to change the icon of a .desktop file,
or 3) if you use the filetypes editor to change the icon for a given mimetype.
These are the three cases I can think of, and they are not as easy to fix.

1) might be solved by clearing the icon name in KFileItem::refresh() -- to be checked
2) might work out of the box via KDirWatch telling KDirLister that this file has changed -- to be checked

3) is the really hard one I think. There is no direct relation between "ksycoca has new definition
for this mimetype" and "we need to clear the cache in all kfileitems". Unless kdirlister does something
like KMimeTypeChooser (connect to KSycoca::self(), SIGNAL(databaseChanged(), 
test for KSycoca::self()->isChanged("mime"), and refresh the mimetype and icon of all fileitems it knows.
This would also fix the case of changing a mimetype pattern, in fact. I guess this doesn't work right now,
hmm, well, until reloading the directory. Yeah maybe we can forget about 3, it's probably
good enough if we say that the user has to reload the directory after changing mimetype

David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).

More information about the kde-core-devel mailing list