Cache for file icons works improperly

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Stefan2, white, sheep, Hacker

Post Reply
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Cache for file icons works improperly

Post by *MarcinW » 2018-07-08, 22:23 UTC

Tested with TC 9.20 64-bit.

Let's assume we have two icon files in some folder:
- iconG.ico (containing just a green square)
- iconR.ico (containing just a red square)

Now do the following:
1) restart TC to be sure, that TC's icon cache is empty

2) rename iconG.ico to iconG_.ico - both icons are shown properly
3) rename iconR.ico to iconG.ico - both icons are shown properly
4) rename iconG_.ico to iconR.ico - both icons are shown properly

5) once again, rename iconG.ico to iconG_.ico - both icons are shown properly
6) once again, rename iconR.ico to iconG.ico - icon for iconG.ico is now shown improperly, as a red square - after pressing F3 on the icon file, we can see that the icon file contains in fact a green square
7) once again, rename iconG_.ico to iconR.ico - both icons are shown improperly now


It seems that renaming an icon should make the cached icon - for previous name - removed.

Regards

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 37410
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) » 2018-07-09, 08:32 UTC

TC does not verify whether a file from which an icon was loaded has changed. This is done for speed reasons - checking this for every single icon displayed would be terribly slow, especially when a virus scanner is active in the background. How often do you reassign icons? Just close and re-open TC when you do this.
Author of Total Commander
http://www.ghisler.com

User avatar
Usher
Senior Member
Senior Member
Posts: 402
Joined: 2011-03-11, 10:11 UTC

Post by *Usher » 2018-07-09, 09:06 UTC

Is there a possibility to force cache refreshing without reopening TC?
Regards from Poland
Andrzej P. Wozniak

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 37410
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) » 2018-07-09, 09:14 UTC

You can send it a WM_SYSCOLORCHANGE message.
Author of Total Commander
http://www.ghisler.com

User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW » 2018-07-09, 13:46 UTC

Well, of course I don't think that TC should monitor file contents. However, we are talking here about changing file names.


I don't know how TC's icon cache is implemented, but I can see the following potential solutions:

1) When renaming any file in TC - for example icon1.ico to icon2.ico - TC should also rename the cache entry assigned for this file; it seems, that currently icon2.ico is added to cache, but cache entry for icon1.ico is NOT invalidated - and it is (improperly) reused when any file named icon1.ico appears in the same folder again.

2) When deleting any file in TC, TC should invalidate cache entry assigned for this file.

3) When panel contents are refreshed (for example because TC has been moved to foreground or Ctrl+R has been used) and some files disappeared, TC should invalidate cache entries assigned for these files.

4) Currently, every icon cache entry contains - at least - file name and its icon image. But file's last modification date could also be added to the cache entry: when entering into any folder, last modification date of each file is read by TC; this date could be just compared with date in the assigned cache entry - any difference means, that the file has been modified asynchronously (for example by using Explorer) - so this single cache entry should be invalidated.


Please note that these solutions should not cause any TC slow down - no whole cache invalidation, no all icons reloading.

What's more, removing invalidated cache entries can lead to memory savings!

Regards

Post Reply