Revision: 28710
http://sourceforge.net/p/bibdesk/svn/28710
Author: hofman
Date: 2024-02-08 19:35:39 +0000 (Thu, 08 Feb 2024)
Log Message:
-----------
no need for instance of image cache as they ae basically just cover methods for
cache file
Modified Paths:
--------------
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.h
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.m
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.h 2024-02-08
19:22:46 UTC (rev 28709)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.h 2024-02-08
19:35:39 UTC (rev 28710)
@@ -49,10 +49,6 @@
Note that the "large" vs. "small" distinction is purely notional. Clients
are free to decide which they will use, as the underlying storage is identical
in either case.
*/
@interface FVCGImageCache : NSObject
-{
-@private;
- FVCacheFile *_cacheFile;
-}
/** @brief Key for caching.
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.m 2024-02-08
19:22:46 UTC (rev 28709)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCGImageCache.m 2024-02-08
19:35:39 UTC (rev 28710)
@@ -46,13 +46,19 @@
@implementation FVCGImageCache
-static FVCGImageCache *_bigImageCache = nil;
-static FVCGImageCache *_smallImageCache = nil;
+static FVCacheFile *_bigImageCache = nil;
+static FVCacheFile *_smallImageCache = nil;
-// sets name for recording/logging statistics
-- (void)setName:(NSString *)name
++ (void)handleAppTerminate:(NSNotification *)notification
{
- [_cacheFile setName:name];
+ // avoid writing to a closed file
+ FVCacheFile *bigImageCache = _bigImageCache;
+ FVCacheFile *smallImageCache = _smallImageCache;
+ _bigImageCache = nil;
+ _smallImageCache = nil;
+ [bigImageCache closeFile];
+ [smallImageCache closeFile];
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
}
+ (void)initialize
@@ -59,58 +65,16 @@
{
FVINITIALIZE(FVCGImageCache);
- _bigImageCache = [FVCGImageCache new];
+ _bigImageCache = [FVCacheFile new];
[_bigImageCache setName:@"full size images"];
- _smallImageCache = [FVCGImageCache new];
+ _smallImageCache = [FVCacheFile new];
[_smallImageCache setName:@"thumbnail images"];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+
selector:@selector(handleAppTerminate:)
+
name:NSApplicationWillTerminateNotification
+ object:nil];
}
-- (id)init
-{
- self = [super init];
- if (self) {
- _cacheFile = [FVCacheFile new];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
-
selector:@selector(handleAppTerminate:)
-
name:NSApplicationWillTerminateNotification
- object:nil];
- }
- return self;
-}
-
-- (void)handleAppTerminate:(NSNotification *)notification
-{
- // avoid writing to a closed file
- FVCacheFile *cacheFile = _cacheFile;
- _cacheFile = nil;
- [cacheFile closeFile];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
-}
-
-- (void)dealloc
-{
- NSLog(@"*** error *** attempt to deallocate FVCGImageCache");
-}
-
-- (CGImageRef)newImageForKey:(id)aKey;
-{
- NSData *data = [_cacheFile dataForKey:aKey];
- CGImageRef image = FVCreateCGImageWithData(data);
- return image;
-}
-
-- (void)cacheImage:(CGImageRef)image forKey:(id)aKey;
-{
- NSData *data = FVCreateDataWithCGImage(image);
- [_cacheFile saveData:data forKey:aKey];
-}
-
-- (void)invalidateCachedImageForKey:(id)aKey
-{
- [_cacheFile invalidateDataForKey:aKey];
-}
-
#pragma mark Class methods
#pragma clang diagnostic push
@@ -124,28 +88,34 @@
+ (CGImageRef)newThumbnailForKey:(id)aKey;
{
- return [_smallImageCache newImageForKey:aKey];
+ NSData *data = [_smallImageCache dataForKey:aKey];
+ CGImageRef image = FVCreateCGImageWithData(data);
+ return image;
}
+ (void)cacheThumbnail:(CGImageRef)image forKey:(id)aKey;
{
- [_smallImageCache cacheImage:image forKey:aKey];
+ NSData *data = FVCreateDataWithCGImage(image);
+ [_smallImageCache saveData:data forKey:aKey];
}
+ (CGImageRef)newImageForKey:(id)aKey;
{
- return [_bigImageCache newImageForKey:aKey];
+ NSData *data = [_bigImageCache dataForKey:aKey];
+ CGImageRef image = FVCreateCGImageWithData(data);
+ return image;
}
+ (void)cacheImage:(CGImageRef)image forKey:(id)aKey;
{
- [_bigImageCache cacheImage:image forKey:aKey];
+ NSData *data = FVCreateDataWithCGImage(image);
+ [_bigImageCache saveData:data forKey:aKey];
}
+ (void)invalidateCachesForKey:(id)aKey;
{
- [_bigImageCache invalidateCachedImageForKey:aKey];
- [_smallImageCache invalidateCachedImageForKey:aKey];
+ [_bigImageCache invalidateDataForKey:aKey];
+ [_smallImageCache invalidateDataForKey:aKey];
}
@end
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit