Patches item #1187816, was opened at 2005-04-21 23:06 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=446897&aid=1187816&group_id=46652
Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Justin Richer (ru2def) Assigned to: Nobody/Anonymous (nobody) Summary: Improved Skin Image Cache Initial Comment: Attached is a patch to improve the liveliness of the skin_utils image caches. The cache will now check against the ST_MTIME of the file it is caching. This behavior allows things like cover images to be changed and have the system notice this without needing to refill/flush the cache externally. This requires a trip to the disk, but a relatively quick one as the OS needs only return the file stats, not the file data. I didn't see a noticeable slowdown on my system. --- skins/main/skin_utils.py.orig 2005-04-21 22:32:55.000000000 -0400 +++ skins/main/skin_utils.py 2005-04-21 23:00:12.000000000 -0400 @@ -44,6 +44,8 @@ import osd import os import util +import stat +import time osd = osd.get_singleton() @@ -69,11 +71,11 @@ if item.media and item.media.item == item: cname = '%s-%s' % (cname, item.media) - - cimage = format_imagecache[cname] - if cimage: - return cimage + cimage = format_imagecache[cname] + + if cimage and (cimage[3] >= os.stat(item.image)[stat.ST_MTIME]): + return cimage[0:3] image = None imagefile = None @@ -83,9 +85,11 @@ image = osd.loadbitmap(item.image) else: image = load_imagecache['thumb://%s' % item.image] - if not image: + if not image or (image[1] < os.stat(item.image)[stat.ST_MTIME]): image = osd.loadbitmap('thumb://%s' % item.image) - load_imagecache['thumb://%s' % item.image] = image + load_imagecache['thumb://%s' % item.image] = (image, int(time.time())) + else: + image = image[0] if item['rotation']: image = pygame.transform.rotate(image, item['rotation']) @@ -128,10 +132,12 @@ return None, 0, 0 image = load_imagecache['thumb://%s' % imagefile] - if not image: + if not image or (image[1] < os.stat(item.image)[stat.ST_MTIME]): image = osd.loadbitmap('thumb://%s' % imagefile) - load_imagecache['thumb://%s' % imagefile] = image - + load_imagecache['thumb://%s' % imagefile] = (image, int(time.time())) + else: + image = image[0] + if not image: return None, 0, 0 @@ -162,7 +168,7 @@ cimage = pygame.transform.scale(image, (width, height)) - format_imagecache[cname] = cimage, width, height + format_imagecache[cname] = cimage, width, height, int(time.time()) return cimage, width, height ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=446897&aid=1187816&group_id=46652 ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Freevo-devel mailing list Freevo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freevo-devel