Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed potential dead-lock on activity indicator

  • Loading branch information...
commit cc381f51a1988889cb3ae7747e1e2615ea04c30d 1 parent d0882e0
@gugmaster gugmaster authored
Showing with 4 additions and 25 deletions.
  1. +4 −25 Core/Source/UIApplication+DTNetworkActivity.m
View
29 Core/Source/UIApplication+DTNetworkActivity.m
@@ -21,22 +21,12 @@ - (void)pushActiveNetworkOperation
{
__internalOperationCount++;
- void (^block)() = ^{
+ dispatch_async(dispatch_get_main_queue(), ^{
if (!self.isNetworkActivityIndicatorVisible && __internalOperationCount)
{
self.networkActivityIndicatorVisible = YES;
}
- };
-
- if (dispatch_get_main_queue() == dispatch_get_current_queue())
- {
- // already on main thread
- block();
- }
- else
- {
- dispatch_async(dispatch_get_main_queue(), block);
- }
+ });
}
}
@@ -52,23 +42,12 @@ - (void)popActiveNetworkOperation
__internalOperationCount--;
- void (^block)() = ^{
+ dispatch_async(dispatch_get_main_queue(), ^{
if (self.isNetworkActivityIndicatorVisible && !__internalOperationCount)
{
self.networkActivityIndicatorVisible = NO;
}
- };
-
-
- if (dispatch_get_main_queue() == dispatch_get_current_queue())
- {
- // already on main thread
- block();
- }
- else
- {
- dispatch_async(dispatch_get_main_queue(), block);
- }
+ });
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.