From 92be178bf2be7d7f27779e53ee9deba7be6f6674 Mon Sep 17 00:00:00 2001 From: matthewleon Date: Sun, 2 Mar 2008 10:51:37 +0000 Subject: [PATCH] Playlist entries are now processed on main thread. --- Playlist/PlaylistLoader.m | 44 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index ec17bdcfd..cc92a666b 100755 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -278,7 +278,7 @@ readEntryInfoOperation = [[[NSInvocationOperation alloc] initWithTarget:self selector:@selector(readEntryInfo:) - object:pe] autorelease]; + object:pe]autorelease]; if (oldReadEntryInfoOperation) { [readEntryInfoOperation addDependency:oldReadEntryInfoOperation]; @@ -309,6 +309,25 @@ return entryInfo; } +- (void)processEntryInfo:(NSInvocationOperation *)operation +{ + NSDictionary *entryInfo = [operation result]; + PlaylistEntry *pe; + // get the playlist entry that the thread was inspecting + [[operation invocation]getArgument:&pe atIndex:2]; + if (entryInfo == nil) + { + pe.error = YES; + pe.errorMessage = @"Unable to retrieve properties."; + } + else + { + [pe setValuesForKeysWithDictionary:entryInfo]; + [playlistController updateTotalTime]; + } + return; +} + - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change @@ -317,30 +336,9 @@ // We finished reading the info for a playlist entry if ([keyPath isEqualToString:@"isFinished"] && [object isFinished]) { - // get the results - NSDictionary *entryInfo = [object result]; - // get the playlist entry that the thread was inspecting - PlaylistEntry *pe; - [[object invocation]getArgument:&pe atIndex:2]; - - if (entryInfo == nil) - { - pe.error = YES; - pe.errorMessage = @"Unable to retrieve properties."; - } - else - { - [pe setValuesForKeysWithDictionary:entryInfo]; - [playlistController updateTotalTime]; - } - - //Hack so the display gets updated - PlaylistEntry *tempEntry = [playlistController currentEntry]; - [playlistController setCurrentEntry:pe]; - [playlistController setCurrentEntry:tempEntry]; - // stop observing [object removeObserver:self forKeyPath:keyPath]; + [self performSelectorOnMainThread:@selector(processEntryInfo:) withObject:object waitUntilDone:NO]; } else {