From fd447230d7d94adf0f2de855bb20c682d8b47a7f Mon Sep 17 00:00:00 2001 From: Peter Date: Thu, 27 Feb 2014 18:03:06 +0400 Subject: [PATCH] Fixed GCD objects under ARC on OS X 10.7 --- MTProtoKit/MTTimer.m | 45 +++++++++++++++------------- MtProtoKit.xcodeproj/project.pbxproj | 4 +-- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/MTProtoKit/MTTimer.m b/MTProtoKit/MTTimer.m index a34f0b4655..9b1deb1467 100644 --- a/MTProtoKit/MTTimer.m +++ b/MTProtoKit/MTTimer.m @@ -8,31 +8,23 @@ #import -#if TARGET_OS_IPHONE - -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later -#define NEEDS_DISPATCH_RETAIN_RELEASE 0 -#else // iOS 5.X or earlier -#define NEEDS_DISPATCH_RETAIN_RELEASE 1 -#endif - -#else - -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later -#define NEEDS_DISPATCH_RETAIN_RELEASE 0 -#else -#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier -#endif - -#endif - @interface MTTimer () +#if OS_OBJECT_USE_OBJC @property (nonatomic, strong) dispatch_source_t timer; +#else +@property (nonatomic) dispatch_source_t timer; +#endif + @property (nonatomic) NSTimeInterval timeout; @property (nonatomic) bool repeat; @property (nonatomic, copy) dispatch_block_t completion; + +#if OS_OBJECT_USE_OBJC @property (nonatomic, strong) dispatch_queue_t queue; +#else +@property (nonatomic) dispatch_queue_t queue; +#endif @end @@ -48,7 +40,10 @@ _timeout = timeout; _repeat = repeat; self.completion = completion; - self.queue = queue; +#if !OS_OBJECT_USE_OBJC + dispatch_retain(queue); +#endif + _queue = queue; } return self; } @@ -58,11 +53,19 @@ if (_timer != nil) { dispatch_source_cancel(_timer); -#if NEEDS_DISPATCH_RETAIN_RELEASE +#if !OS_OBJECT_USE_OBJC dispatch_release(_timer); #endif _timer = nil; } + + if (_queue != nil) + { +#if !OS_OBJECT_USE_OBJC + dispatch_release(_queue); +#endif + _queue = nil; + } } - (void)start @@ -99,7 +102,7 @@ if (_timer != nil) { dispatch_source_cancel(_timer); -#if NEEDS_DISPATCH_RETAIN_RELEASE +#if !OS_OBJECT_USE_OBJC dispatch_release(_timer); #endif _timer = nil; diff --git a/MtProtoKit.xcodeproj/project.pbxproj b/MtProtoKit.xcodeproj/project.pbxproj index 98eb59aa5d..1e1ba03390 100644 --- a/MtProtoKit.xcodeproj/project.pbxproj +++ b/MtProtoKit.xcodeproj/project.pbxproj @@ -1783,7 +1783,7 @@ "$(PROJECT_DIR)/openssl", "$(PROJECT_DIR)/openssl/OSX", ); - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.7; PRODUCT_NAME = MTProtoKit; SDKROOT = macosx; WRAPPER_EXTENSION = framework; @@ -1817,7 +1817,7 @@ "$(PROJECT_DIR)/openssl", "$(PROJECT_DIR)/openssl/OSX", ); - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.7; PRODUCT_NAME = MTProtoKit; SDKROOT = macosx; WRAPPER_EXTENSION = framework;