Browse Source

Robustify media library updating

Updating the library always on the main thread prevents a race condition between multiple threads interacting with the poor, innocent core data backend.
Felix Paul Kühne 11 years ago
parent
commit
be49a67713

+ 1 - 1
Sources/VLCDropboxController.m

@@ -144,7 +144,7 @@
 {
     /* update library now that we got a file */
     VLCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
-    [appDelegate updateMediaList];
+    [appDelegate performSelectorOnMainThread:@selector(updateMediaList) withObject:nil waitUntilDone:NO];
 
     if ([self.delegate respondsToSelector:@selector(operationWithProgressInformationStopped)])
         [self.delegate operationWithProgressInformationStopped];

+ 1 - 1
Sources/VLCGoogleDriveController.m

@@ -238,7 +238,7 @@
     /* update library now that we got a file */
     APLog(@"DriveFile download was successful");
     VLCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
-    [appDelegate updateMediaList];
+    [appDelegate performSelectorOnMainThread:@selector(updateMediaList) withObject:nil waitUntilDone:NO];
 
     if ([self.delegate respondsToSelector:@selector(operationWithProgressInformationStopped)])
         [self.delegate operationWithProgressInformationStopped];

+ 1 - 1
Sources/VLCHTTPFileDownloader.m

@@ -116,7 +116,7 @@
 -(void)connectionDidFinishLoading:(NSURLConnection *)connection {
     APLog(@"http file download complete");
     VLCAppDelegate * appDelegate = [UIApplication sharedApplication].delegate;
-    [appDelegate updateMediaList];
+    [appDelegate performSelectorOnMainThread:@selector(updateMediaList) withObject:nil waitUntilDone:NO];
 
     [self _downloadEnded];
 }

+ 1 - 1
Sources/VLCHTTPUploaderController.m

@@ -159,7 +159,7 @@
 
     /* update media library when file upload was completed */
     VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
-    [appDelegate updateMediaList];
+    [appDelegate performSelectorOnMainThread:@selector(updateMediaList) withObject:nil waitUntilDone:NO];
 }
 
 @end