Permalink
Browse files

Updates for Xcode 4.5+ (dispatch_retain & dispatch_release no longer …

…needed under latest ARC)
  • Loading branch information...
1 parent d90f7bd commit fa461604e6899bfd88cd199bec479265c93626d3 @robbiehanson committed Jul 3, 2012
View
@@ -6,6 +6,32 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+/**
+ * Does ARC support support GCD objects?
+ * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+**/
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #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
+
+ // Compiling for Mac OS X
+
+ #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
+
// Log levels: off, error, warn, info, verbose
#if DEBUG
static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN;
@@ -34,7 +60,9 @@ - (id)initWithDispatchQueue:(dispatch_queue_t)queue
if (queue)
{
moduleQueue = queue;
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_retain(moduleQueue);
+ #endif
}
else
{
@@ -49,7 +77,9 @@ - (id)initWithDispatchQueue:(dispatch_queue_t)queue
- (void)dealloc
{
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(moduleQueue);
+ #endif
}
/**
View
@@ -572,7 +572,8 @@ static void xmpp_xmlStartElement(void *ctx, const xmlChar *nodeName,
if (newNode->nsDef == NULL)
{
- newNode->nsDef = lastAddedNs = newNs;
+ newNode->nsDef = newNs;
+ lastAddedNs = newNs;
}
else
{
@@ -608,12 +609,11 @@ static void xmpp_xmlStartElement(void *ctx, const xmlChar *nodeName,
if (newNode->nsDef == NULL)
{
- newNode->nsDef = lastAddedNs = newNs;
+ newNode->nsDef = newNs;
}
else
{
lastAddedNs->next = newNs;
- lastAddedNs = newNs;
}
newNode->ns = newNs;
View
@@ -17,6 +17,32 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+/**
+ * Does ARC support support GCD objects?
+ * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+**/
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #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
+
+ // Compiling for Mac OS X
+
+ #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
+
// Log levels: off, error, warn, info, verbose
#if DEBUG
static const int xmppLogLevel = XMPP_LOG_LEVEL_INFO | XMPP_LOG_FLAG_SEND_RECV; // | XMPP_LOG_FLAG_TRACE;
@@ -177,8 +203,10 @@ - (id)initP2PFrom:(XMPPJID *)jid
**/
- (void)dealloc
{
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(xmppQueue);
dispatch_release(parserQueue);
+ #endif
[asyncSocket setDelegate:nil delegateQueue:NULL];
[asyncSocket disconnect];
@@ -3318,8 +3346,10 @@ - (void)xmppParser:(XMPPParser *)sender didReadElement:(NSXMLElement *)element
[self sendElement:iqResponse];
}
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(delSemaphore);
dispatch_release(delGroup);
+ #endif
}});
@@ -3405,12 +3435,14 @@ - (void)setupKeepAliveTimer
[self keepAlive];
}});
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_source_t theKeepAliveTimer = keepAliveTimer;
dispatch_source_set_cancel_handler(keepAliveTimer, ^{
XMPPLogVerbose(@"dispatch_release(keepAliveTimer)");
dispatch_release(theKeepAliveTimer);
});
+ #endif
// Everytime we send or receive data, we update our lastSendReceiveTime.
// We set our timer to fire several times per keepAliveInterval.
@@ -3862,7 +3894,9 @@ - (BOOL)wait:(NSTimeInterval)timeout_seconds
- (void)dealloc
{
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(semaphore);
+ #endif
}
@end
@@ -12,6 +12,32 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+/**
+ * Does ARC support support GCD objects?
+ * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+**/
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #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
+
+ // Compiling for Mac OS X
+
+ #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
+
// Log levels: off, error, warn, info, verbose
#if DEBUG
static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN;
@@ -819,10 +845,10 @@ - (void)dealloc
[[self class] unregisterDatabaseFileName:databaseFileName];
}
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
if (storageQueue)
- {
dispatch_release(storageQueue);
- }
+ #endif
}
@end
@@ -7,6 +7,32 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+/**
+ * Does ARC support support GCD objects?
+ * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+**/
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #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
+
+ // Compiling for Mac OS X
+
+ #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
+
#define IMPOSSIBLE_REACHABILITY_FLAGS 0xFFFFFFFF
// Log levels: off, error, warn, info, verbose
@@ -386,12 +412,14 @@ - (void)setupReconnectTimer
}});
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_source_t theReconnectTimer = reconnectTimer;
dispatch_source_set_cancel_handler(reconnectTimer, ^{
XMPPLogVerbose(@"dispatch_release(reconnectTimer)");
dispatch_release(theReconnectTimer);
});
+ #endif
dispatch_time_t startTime;
if (reconnectDelay > 0.0)
@@ -613,9 +641,10 @@ - (void)maybeAttemptReconnectWithReachabilityFlags:(SCNetworkReachabilityFlags)r
}});
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(delSemaphore);
dispatch_release(delGroup);
-
+ #endif
}});
}
@@ -7,9 +7,35 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+/**
+ * Does ARC support support GCD objects?
+ * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+**/
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #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
+
+ // Compiling for Mac OS X
+
+ #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
+
// Log levels: off, error, warn, info, verbose
#if DEBUG
- static const int xmppLogLevel = XMPP_LOG_LEVEL_VERBOSE | XMPP_LOG_FLAG_TRACE;
+ static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN; // | XMPP_LOG_FLAG_TRACE;
#else
static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN;
#endif
@@ -401,7 +427,9 @@ - (void)destroyDeleteTimer
if (deleteTimer)
{
dispatch_source_cancel(deleteTimer);
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(deleteTimer);
+ #endif
deleteTimer = NULL;
}
}
Oops, something went wrong.

0 comments on commit fa46160

Please sign in to comment.