Remove concurrency! Mwahaha! Also, moved updateTotalTime so it's done after all operations. Now it's actually usable while loading time.
This commit is contained in:
parent
dd89208ee0
commit
cf46d16a56
2 changed files with 18 additions and 12 deletions
|
@ -73,7 +73,6 @@
|
||||||
[super awakeFromNib];
|
[super awakeFromNib];
|
||||||
|
|
||||||
[self addObserver:self forKeyPath:@"arrangedObjects" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil];
|
[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
|
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||||
|
@ -83,10 +82,6 @@
|
||||||
[self updatePlaylistIndexes];
|
[self updatePlaylistIndexes];
|
||||||
[self updateTotalTime];
|
[self updateTotalTime];
|
||||||
}
|
}
|
||||||
else if ([keyPath isEqualToString:@"length"])
|
|
||||||
{
|
|
||||||
[self updateTotalTime];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updatePlaylistIndexes
|
- (void)updatePlaylistIndexes
|
||||||
|
|
|
@ -267,28 +267,39 @@
|
||||||
|
|
||||||
//Select the first entry in the group that was just added
|
//Select the first entry in the group that was just added
|
||||||
[playlistController setSelectionIndex:index];
|
[playlistController setSelectionIndex:index];
|
||||||
|
[self performSelectorInBackground:@selector(loadInfoForEntries:) withObject:entries];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)loadInfoForEntries:(NSArray *)entries
|
||||||
|
{
|
||||||
NSOperationQueue *queue;
|
NSOperationQueue *queue;
|
||||||
queue = [[[NSApplication sharedApplication] delegate] sharedOperationQueue];
|
queue = [[[NSApplication sharedApplication] delegate] sharedOperationQueue];
|
||||||
|
|
||||||
|
NSInvocationOperation *oldReadEntryInfoOperation = Nil;
|
||||||
for (PlaylistEntry *pe in entries)
|
for (PlaylistEntry *pe in entries)
|
||||||
{
|
{
|
||||||
NSInvocationOperation *readEntryInfoOperation;
|
NSInvocationOperation *readEntryInfoOperation;
|
||||||
readEntryInfoOperation = [[NSInvocationOperation alloc]
|
readEntryInfoOperation = [[[NSInvocationOperation alloc]
|
||||||
initWithTarget:self
|
initWithTarget:self
|
||||||
selector:@selector(readEntryInfo:)
|
selector:@selector(readEntryInfo:)
|
||||||
object:pe];
|
object:pe]autorelease];
|
||||||
|
if (oldReadEntryInfoOperation)
|
||||||
|
{
|
||||||
|
[readEntryInfoOperation addDependency:oldReadEntryInfoOperation];
|
||||||
|
[oldReadEntryInfoOperation release];
|
||||||
|
}
|
||||||
[readEntryInfoOperation addObserver:self
|
[readEntryInfoOperation addObserver:self
|
||||||
forKeyPath:@"isFinished"
|
forKeyPath:@"isFinished"
|
||||||
options:NSKeyValueObservingOptionNew
|
options:NSKeyValueObservingOptionNew
|
||||||
context:NULL];
|
context:NULL];
|
||||||
[queue addOperation:readEntryInfoOperation];
|
[queue addOperation:readEntryInfoOperation];
|
||||||
|
oldReadEntryInfoOperation = [readEntryInfoOperation retain];
|
||||||
[readEntryInfoOperation release];
|
|
||||||
}
|
}
|
||||||
|
[oldReadEntryInfoOperation release];
|
||||||
|
|
||||||
return;
|
[queue waitUntilAllOperationsAreFinished];
|
||||||
|
|
||||||
|
[playlistController performSelectorOnMainThread:@selector(updateTotalTime) withObject:nil waitUntilDone:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary *)readEntryInfo:(PlaylistEntry *)pe
|
- (NSDictionary *)readEntryInfo:(PlaylistEntry *)pe
|
||||||
|
|
Loading…
Reference in a new issue