Authored by Olivier Poitrey

Set references to nil after release in dealloc methods

... ... @@ -4,7 +4,7 @@
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
*/
#import "SDImageCache.h"
#import <CommonCrypto/CommonDigest.h>
... ... @@ -39,7 +39,7 @@ static SDImageCache *instance;
// Init the disk cache
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
diskCachePath = [[[paths objectAtIndex:0] stringByAppendingPathComponent:@"ImageCache"] retain];
if (![[NSFileManager defaultManager] fileExistsAtPath:diskCachePath])
{
[[NSFileManager defaultManager] createDirectoryAtPath:diskCachePath attributes:nil];
... ... @@ -52,13 +52,13 @@ static SDImageCache *instance;
// Subscribe to app events
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didReceiveMemoryWarning:)
name:UIApplicationDidReceiveMemoryWarningNotification
name:UIApplicationDidReceiveMemoryWarningNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(willTerminate)
name:UIApplicationWillTerminateNotification
object:nil];
name:UIApplicationWillTerminateNotification
object:nil];
}
return self;
... ... @@ -66,18 +66,18 @@ static SDImageCache *instance;
- (void)dealloc
{
[memCache release];
[diskCachePath release];
[cacheInQueue release];
[memCache release], memCache = nil;
[diskCachePath release], diskCachePath = nil;
[cacheInQueue release], cacheInQueue = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIApplicationDidReceiveMemoryWarningNotification
object:nil];
name:UIApplicationDidReceiveMemoryWarningNotification
object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIApplicationWillTerminateNotification
object:nil];
name:UIApplicationWillTerminateNotification
object:nil];
[super dealloc];
}
... ... @@ -89,7 +89,7 @@ static SDImageCache *instance;
{
instance = [[SDImageCache alloc] init];
}
return instance;
}
... ... @@ -134,7 +134,7 @@ static SDImageCache *instance;
[memCache setObject:image forKey:key];
if (toDisk)
{
{
[cacheInQueue addOperation:[[[NSInvocationOperation alloc] initWithTarget:self selector:@selector(storeKeyToDisk:) object:key] autorelease]];
}
}
... ... @@ -187,7 +187,7 @@ static SDImageCache *instance;
{
[cacheInQueue cancelAllOperations];
[[NSFileManager defaultManager] removeItemAtPath:diskCachePath error:nil];
[[NSFileManager defaultManager] createDirectoryAtPath:diskCachePath attributes:nil];
[[NSFileManager defaultManager] createDirectoryAtPath:diskCachePath attributes:nil];
}
- (void)cleanDisk
... ...
... ... @@ -16,7 +16,7 @@ static NSOperationQueue *downloadQueue;
- (void)dealloc
{
[url release];
[url release], url = nil;
[super dealloc];
}
... ... @@ -33,7 +33,7 @@ static NSOperationQueue *downloadQueue;
}
[downloadQueue addOperation:downloader];
return downloader;
}
... ... @@ -54,7 +54,7 @@ static NSOperationQueue *downloadQueue;
// In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:5];
UIImage *image = [UIImage imageWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:NULL]];
if (!self.isCancelled && [delegate respondsToSelector:@selector(imageDownloader:didFinishWithImage:)])
{
[delegate performSelector:@selector(imageDownloader:didFinishWithImage:) withObject:self withObject:image];
... ...
... ... @@ -4,7 +4,7 @@
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
*/
#import <UIKit/UIKit.h>
#import "SDWebImageDownloaderDelegate.h"
... ...
... ... @@ -4,7 +4,7 @@
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
*/
#import "SDWebImageManager.h"
#import "SDImageCache.h"
... ... @@ -26,12 +26,12 @@ static SDWebImageManager *instance;
return self;
}
- (void) dealloc
- (void)dealloc
{
[delegates release];
[downloaders release];
[downloaderForURL release];
[failedURLs release];
[delegates release], delegates = nil;
[downloaders release], downloaders = nil;
[downloaderForURL release], downloaderForURL = nil;
[failedURLs release], failedURLs = nil;
[super dealloc];
}
... ... @@ -86,7 +86,7 @@ static SDWebImageManager *instance;
}
SDWebImageDownloader *downloader = [[downloaders objectAtIndex:idx] retain];
[delegates removeObjectAtIndex:idx];
[downloaders removeObjectAtIndex:idx];
... ...
... ... @@ -4,7 +4,7 @@
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
*/
#import <UIKit/UIKit.h>
#import "SDWebImageManagerDelegate.h"
... ...
... ... @@ -4,7 +4,7 @@
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
*/
#import "UIImageView+WebCache.h"
#import "SDWebImageManager.h"
... ... @@ -45,4 +45,4 @@
self.image = image;
}
@end
\ No newline at end of file
@end
... ...