Fixed a potential crash when the delegate retainCount = 1, which means the delegate is only retained by the SDWebImageManager and the delegate's dealloc method has a structure like the code below.

- (void)dealloc
{
    [manager cancelForDelegate:self];
    [super dealloc];
}
This commit is contained in:
nonamelive 2011-09-28 14:29:51 +08:00
parent e9d43e443a
commit 2b0bb248f4
1 changed files with 2 additions and 2 deletions

View File

@ -175,7 +175,7 @@ static SDWebImageManager *instance;
SDWebImageDownloader *aDownloader = [downloaders objectAtIndex:uidx];
if (aDownloader == downloader)
{
id<SDWebImageManagerDelegate> delegate = [downloadDelegates objectAtIndex:uidx];
id<SDWebImageManagerDelegate> delegate = [[[downloadDelegates objectAtIndex:uidx] retain] autorelease];
if (image)
{
@ -228,7 +228,7 @@ static SDWebImageManager *instance;
SDWebImageDownloader *aDownloader = [downloaders objectAtIndex:uidx];
if (aDownloader == downloader)
{
id<SDWebImageManagerDelegate> delegate = [downloadDelegates objectAtIndex:uidx];
id<SDWebImageManagerDelegate> delegate = [[[downloadDelegates objectAtIndex:uidx] retain] autorelease];
if ([delegate respondsToSelector:@selector(webImageManager:didFailWithError:)])
{