Remove concurrency! Mwahaha! Also, moved updateTotalTime so it's done after all operations. Now it's actually usable while loading time.

CQTexperiment
vspader 2008-03-03 02:25:52 +00:00
parent dd89208ee0
commit cf46d16a56
2 changed files with 18 additions and 12 deletions

View File

@ -73,7 +73,6 @@
[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
@ -83,10 +82,6 @@
[self updatePlaylistIndexes];
[self updateTotalTime];
}
else if ([keyPath isEqualToString:@"length"])
{
[self updateTotalTime];
}
}
- (void)updatePlaylistIndexes

View File

@ -267,28 +267,39 @@
//Select the first entry in the group that was just added
[playlistController setSelectionIndex:index];
[self performSelectorInBackground:@selector(loadInfoForEntries:) withObject:entries];
}
- (void)loadInfoForEntries:(NSArray *)entries
{
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];
object:pe]autorelease];
if (oldReadEntryInfoOperation)
{
[readEntryInfoOperation addDependency:oldReadEntryInfoOperation];
[oldReadEntryInfoOperation release];
}
[readEntryInfoOperation addObserver:self
forKeyPath:@"isFinished"
options:NSKeyValueObservingOptionNew
context:NULL];
[queue addOperation:readEntryInfoOperation];
[readEntryInfoOperation release];
oldReadEntryInfoOperation = [readEntryInfoOperation retain];
}
[oldReadEntryInfoOperation release];
return;
[queue waitUntilAllOperationsAreFinished];
[playlistController performSelectorOnMainThread:@selector(updateTotalTime) withObject:nil waitUntilDone:NO];
}
- (NSDictionary *)readEntryInfo:(PlaylistEntry *)pe