crash in using soundNamed:
crash in using soundNamed:
- Subject: crash in using soundNamed:
- From: Mitchell Livingston <email@hidden>
- Date: Wed, 24 Oct 2007 13:07:58 -0400
I have the following code to generate a list of sounds for a menu item:
- (NSArray *) sounds
{
NSMutableArray * sounds = [NSMutableArray array];
NSArray * directories = [NSArray arrayWithObjects: @"/System/
Library/Sounds", @"/Library/Sounds",
[NSHomeDirectory()
stringByAppendingPathComponent: @"Library/Sounds"], nil];
BOOL isDirectory;
NSEnumerator * soundEnumerator;
NSString * sound;
NSString * directory;
NSEnumerator * enumerator = [directories objectEnumerator];
while ((directory = [enumerator nextObject]))
if ([[NSFileManager defaultManager] fileExistsAtPath:
directory isDirectory: &isDirectory] && isDirectory)
{
soundEnumerator = [[[NSFileManager defaultManager]
directoryContentsAtPath: directory] objectEnumerator];
while ((sound = [soundEnumerator nextObject]))
{
sound = [sound stringByDeletingPathExtension];
if ([NSSound soundNamed: sound])
[sounds addObject: sound];
}
}
return sounds;
}
Some users are reporting crashes when using this with custom sounds
in one of the directories.
I'm a bit confused on how this could crash in soundNamed. A crash log
is:
Thread 0 Crashed:
0 com.apple.AppKit 0x93436ae4 -[NSSound _postInitialization] + 749
1 com.apple.AppKit 0x9369d868 -[NSSound
initWithContentsOfURL:byReference:] + 256
2 com.apple.AppKit 0x9369e7a3 +[NSSound _searchForSoundNamed:] + 626
3 com.apple.AppKit 0x9369e8a5 +[NSSound soundNamed:] + 203
4 org.m0k.transmission 0x00010829 -[PrefsController sounds] + 339
5 com.apple.AppKit 0x934e200b -[NSBinder
_valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:] + 733
6 com.apple.AppKit 0x934e1c9e -[NSBinder
valueForBinding:resolveMarkersToPlaceholders:] + 192
7 com.apple.AppKit 0x935155a5 -[NSSelectionBinder
_adjustObject:mode:observedController:observedKeyPath:context:editableSt
ate:adjustState:] + 1103
8 com.apple.AppKit 0x934e149a -[NSValueBinder
_observeValueForKeyPath:ofObject:context:] + 280
9 com.apple.AppKit 0x9351514c -[NSSelectionBinder
observeValueForKeyPath:ofObject:change:context:] + 308
10 com.apple.AppKit 0x934e1271 -[NSBinder
_performConnectionEstablishedRefresh] + 78
11 com.apple.AppKit 0x934d98da -[NSObject(NSKeyValueBindingCreation)
bind:toObject:withKeyPath:options:] + 763
Thanks a lot,
Mitch Livingston
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden