• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

BathyScapheで画像のインラインプレビューを可能にするプラグイン


Commit MetaInfo

修訂308f3a19d0af4a2444d7bbe35dc1a600bffbbaeb (tree)
時間2012-05-18 20:46:22
作者masakih <masakih@user...>
Commitermasakih

Log Message

[Mod] サムネイルをキャッシュするように変更

Change Summary

差異

--- a/BSInlinePreviewer.m
+++ b/BSInlinePreviewer.m
@@ -441,7 +441,7 @@ const NSUInteger alreadyPreviewed = NSNotFound - 1;
441441 - (NSImage *)downloadImageURL:(NSURL *)imageURL
442442 {
443443 NSImage *cachedImage = [cache objectForKey:[self cacheKeyForURL:imageURL]];
444- if(cachedImage) return [self fitImage:cachedImage toSize:[self previewSize]];;
444+ if(cachedImage) return cachedImage;
445445
446446 NSURLRequest *req;
447447
@@ -457,24 +457,27 @@ const NSUInteger alreadyPreviewed = NSNotFound - 1;
457457 error:&err];
458458 if(err) {
459459 NSLog(@"Fail download. reason(%@)", [err localizedDescription]);
460- return [self notFoundImage];
460+ goto notFound;
461461 }
462462 if(res) {
463463 if(![[res MIMEType] hasPrefix:@"image/"]) {
464464 NSLog(@"Fail download. reason(target type is %@)", [res MIMEType]);
465- return [self notFoundImage];
465+ goto notFound;
466466 }
467467 }
468468
469469 NSImage *image = [[[NSImage alloc] initWithData:imageData] autorelease];
470470 if(!image) {
471471 NSLog(@"Can not create image.");
472- return [self notFoundImage];
472+ goto notFound;
473473 }
474474
475- [cache setObject:image forKey:[self cacheKeyForURL:imageURL]];
476-
477- return [self fitImage:image toSize:[self previewSize]];
475+ cachedImage = [self fitImage:image toSize:[self previewSize]];
476+ [cache setObject:cachedImage forKey:[self cacheKeyForURL:imageURL]];
477+ return cachedImage;
478+notFound:
479+ [cache setObject:[self notFoundImage] forKey:[self cacheKeyForURL:imageURL]];
480+ return [self notFoundImage];
478481 }
479482
480483 @end