Update for #1802 - made sure we don’t get into problems when checking for self.a…
…ctivityIndicator on one thread and allocating on another. Also, made sure `sd_removeActivityIndicator` executes on the main queue
Showing
1 changed file
with
9 additions
and
10 deletions
@@ -156,8 +156,8 @@ static char TAG_ACTIVITY_SHOW; | @@ -156,8 +156,8 @@ static char TAG_ACTIVITY_SHOW; | ||
156 | 156 | ||
157 | - (void)sd_addActivityIndicator { | 157 | - (void)sd_addActivityIndicator { |
158 | #if SD_UIKIT | 158 | #if SD_UIKIT |
159 | - if (!self.activityIndicator) { | ||
160 | - dispatch_main_async_safe(^{ | 159 | + dispatch_main_async_safe(^{ |
160 | + if (!self.activityIndicator) { | ||
161 | self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:[self sd_getIndicatorStyle]]; | 161 | self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:[self sd_getIndicatorStyle]]; |
162 | self.activityIndicator.translatesAutoresizingMaskIntoConstraints = NO; | 162 | self.activityIndicator.translatesAutoresizingMaskIntoConstraints = NO; |
163 | 163 | ||
@@ -177,10 +177,7 @@ static char TAG_ACTIVITY_SHOW; | @@ -177,10 +177,7 @@ static char TAG_ACTIVITY_SHOW; | ||
177 | attribute:NSLayoutAttributeCenterY | 177 | attribute:NSLayoutAttributeCenterY |
178 | multiplier:1.0 | 178 | multiplier:1.0 |
179 | constant:0.0]]; | 179 | constant:0.0]]; |
180 | - }); | ||
181 | - } | ||
182 | - | ||
183 | - dispatch_main_async_safe(^{ | 180 | + } |
184 | [self.activityIndicator startAnimating]; | 181 | [self.activityIndicator startAnimating]; |
185 | }); | 182 | }); |
186 | #endif | 183 | #endif |
@@ -188,10 +185,12 @@ static char TAG_ACTIVITY_SHOW; | @@ -188,10 +185,12 @@ static char TAG_ACTIVITY_SHOW; | ||
188 | 185 | ||
189 | - (void)sd_removeActivityIndicator { | 186 | - (void)sd_removeActivityIndicator { |
190 | #if SD_UIKIT | 187 | #if SD_UIKIT |
191 | - if (self.activityIndicator) { | ||
192 | - [self.activityIndicator removeFromSuperview]; | ||
193 | - self.activityIndicator = nil; | ||
194 | - } | 188 | + dispatch_main_async_safe(^{ |
189 | + if (self.activityIndicator) { | ||
190 | + [self.activityIndicator removeFromSuperview]; | ||
191 | + self.activityIndicator = nil; | ||
192 | + } | ||
193 | + }); | ||
195 | #endif | 194 | #endif |
196 | } | 195 | } |
197 | 196 |
-
Please register or login to post a comment