瀏覽代碼

fix crash: delegate callback which triggered layout in background thread

Tobias Conradi 9 年之前
父節點
當前提交
7f6c27cf59
共有 1 個文件被更改,包括 8 次插入2 次删除
  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