Browse Source

MacOSX/Framework: Don't attempt to set a value of a dictionary that is being monitored by KVO on non-main thread. That's not thread-safe.

Pierre d'Herbemont 17 years ago
parent
commit
fa91ce4757
1 changed files with 7 additions and 4 deletions
  1. 7 4
      Sources/VLCMedia.m

+ 7 - 4
Sources/VLCMedia.m

@@ -74,6 +74,7 @@ NSString * VLCMediaMetaChanged              = @"VLCMediaMetaChanged";
 /* Operations */
 - (void)fetchMetaInformationFromLibVLCWithType:(NSString*)metaType;
 - (void)fetchMetaInformationForArtWorkWithURL:(NSString *)anURL;
+- (void)setArtwork:(NSImage *)art;
 
 /* Callback Methods */
 - (void)metaChanged:(NSString *)metaType;
@@ -496,15 +497,17 @@ static void HandleMediaSubItemAdded(const libvlc_event_t * event, void * self)
     // If anything was found, lets save it to the meta data dictionary
     if (art)
     {
-        @synchronized(metaDictionary) 
-        {
-            [metaDictionary setObject:art forKey:VLCMetaInformationArtwork];
-        }
+        [self performSelectorOnMainThread:@selector(setArtwork:) withObject:art waitUntilDone:NO];
     }
 
     [pool release];
 }
 
+- (void)setArtwork:(NSImage *)art
+{
+    [metaDictionary setObject:art forKey:@"artwork"];
+}
+
 - (void)metaChanged:(NSString *)metaType
 {
     [self fetchMetaInformationFromLibVLCWithType:metaType];