Forráskód Böngészése

fix crash: delegate callback which triggered layout in background thread

Tobias Conradi 9 éve
szülő
commit
7f6c27cf59
1 módosított fájl, 8 hozzáadás és 2 törlés
  1. 8 2
      Sources/VLCSharedLibraryParser.m

+ 8 - 2
Sources/VLCSharedLibraryParser.m

@@ -53,8 +53,14 @@ NSString *const VLCSharedLibraryParserDeterminedNetserviceAsVLCInstance = @"VLCS
 {
     NSArray *parsedContents = [self downloadAndProcessDataFromServer:hostnameAndPort];
 
-    if ([self.delegate respondsToSelector:@selector(sharedLibraryDataProcessings:)])
-        [self.delegate sharedLibraryDataProcessings:parsedContents];
+    __weak typeof(self) weakSelf = self;
+    [[NSOperationQueue mainQueue] addOperationWithBlock:^{
+        id delegate = weakSelf.delegate;
+        if ([delegate respondsToSelector:@selector(sharedLibraryDataProcessings:)]) {
+            [delegate sharedLibraryDataProcessings:parsedContents];
+        }
+    }];
+
 }
 
 - (NSArray *)downloadAndProcessDataFromServer:(NSString *)hostnamePort