diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 5721e912b..89174987d 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -73,15 +73,20 @@ [super awakeFromNib]; [self addObserver:self forKeyPath:@"arrangedObjects" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil]; + [self addObserver:self forKeyPath:@"arrangedObjects.length" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if ([keyPath isEqualToString:@"arrangedObjects"]) + if ([keyPath isEqualToString:@"arrangedObjects"]) { [self updatePlaylistIndexes]; [self updateTotalTime]; } + else if ([keyPath isEqualToString:@"length"]) + { + [self updateTotalTime]; + } } - (void)updatePlaylistIndexes diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index cc92a666b..2edaeaaa5 100755 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -271,27 +271,23 @@ NSOperationQueue *queue; queue = [[[NSApplication sharedApplication] delegate] sharedOperationQueue]; - NSInvocationOperation *oldReadEntryInfoOperation = Nil; for (PlaylistEntry *pe in entries) { NSInvocationOperation *readEntryInfoOperation; - readEntryInfoOperation = [[[NSInvocationOperation alloc] + readEntryInfoOperation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(readEntryInfo:) - object:pe]autorelease]; - if (oldReadEntryInfoOperation) - { - [readEntryInfoOperation addDependency:oldReadEntryInfoOperation]; - [oldReadEntryInfoOperation release]; - } + object:pe]; + [readEntryInfoOperation addObserver:self forKeyPath:@"isFinished" options:NSKeyValueObservingOptionNew context:NULL]; [queue addOperation:readEntryInfoOperation]; - oldReadEntryInfoOperation = [readEntryInfoOperation retain]; + + [readEntryInfoOperation release]; } - [oldReadEntryInfoOperation release]; + return; } @@ -323,7 +319,6 @@ else { [pe setValuesForKeysWithDictionary:entryInfo]; - [playlistController updateTotalTime]; } return; } @@ -339,6 +334,7 @@ // stop observing [object removeObserver:self forKeyPath:keyPath]; [self performSelectorOnMainThread:@selector(processEntryInfo:) withObject:object waitUntilDone:NO]; + } else {