From b271cbb371f4e98cc5de8ee9c310690bfee1ee65 Mon Sep 17 00:00:00 2001 From: Konstantinos K Date: Wed, 10 Dec 2014 14:42:43 +0200 Subject: [PATCH] initialise kPNGSignatureData data in SDImageCache initWithNamespace method. This ensures the kPNGSignatureData is always initialised even if the we alloc SDImageCache without using the sharedImageCache singleton --- SDWebImage/SDImageCache.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SDWebImage/SDImageCache.m b/SDWebImage/SDImageCache.m index 36bb751a..dbc2d969 100644 --- a/SDWebImage/SDImageCache.m +++ b/SDWebImage/SDImageCache.m @@ -48,7 +48,6 @@ BOOL ImageDataHasPNGPreffix(NSData *data) { static id instance; dispatch_once(&once, ^{ instance = [self new]; - kPNGSignatureData = [NSData dataWithBytes:kPNGSignatureBytes length:8]; }); return instance; } @@ -61,6 +60,9 @@ BOOL ImageDataHasPNGPreffix(NSData *data) { if ((self = [super init])) { NSString *fullNamespace = [@"com.hackemist.SDWebImageCache." stringByAppendingString:ns]; + // initialise PNG signature data + kPNGSignatureData = [NSData dataWithBytes:kPNGSignatureBytes length:8]; + // Create IO serial queue _ioQueue = dispatch_queue_create("com.hackemist.SDWebImageCache", DISPATCH_QUEUE_SERIAL);