Tom,
Have you used 'Shark' and 'Sample' to figure out why it is slow?

Please log a bug (bugreporter.apple.com) if you believe it is slow due to the 
framework. Please include any samples/shark results, and ideally a test case.

corbin

On Oct 7, 2009, at 11:01 PM, Thomas Wetmore wrote:

> I use the following function to show an open panel and get the path to a 
> file. I have inserted three NSLog calls.
> 
> This first time I call this function the panel opens immediately and the 
> three log messages follow each other immediately.
> 
> The second and every later time I call this function, performance is terrible 
> -- there is about two or three seconds between the first two log messages 
> though the third follows immediately after the second.
> 
> The evidence is that [NSOpenPanel openPanel] is the culprit. Is there 
> something I need to do (i.e., close) to the open panel before I return from 
> this function? I tried making the openPanel static and only creating it once, 
> but this caused a crash.
> 
> Thanks very much for any advice.
> 
> Tom Wetmore
> 
> 
> // Use a NSOpenPanel to choose the name of a Gedcom file to read.
> //----------------------------------------------------------------------------------------------------------------------
> NSString* openFile (NSString* title)
> {     
>       NSLog(@"openFile called"); // TODO: Remove.
>       NSOpenPanel* oPanel = [NSOpenPanel openPanel];  <<<<<-------PERFORMANCE 
> SUFFERS HERE---------<<<<
>       NSLog(@"back from openening panel"); // TODO: Remove.
>       [oPanel setCanChooseDirectories: NO];
>       [oPanel setCanChooseFiles: YES];
>       [oPanel setCanCreateDirectories: NO];
>       [oPanel setAllowsMultipleSelection: NO];
>       [oPanel setAlphaValue: 0.99];
>       [oPanel setTitle: title];
>       NSArray* fileTypes = [NSArray arrayWithObjects: @"txt", @"ged", 
> @"gedcom", nil];
>       [oPanel setAllowedFileTypes: fileTypes];
>       NSLog(@"about to runModal"); // TODO: Remove
>       if ([oPanel runModal] != NSOKButton) return @"";
>       
>       // Return the file name.
>       NSArray* files = [oPanel filenames];
>       if ([files count] == 0) return @"";
>       NSString* filePath = [files objectAtIndex:0];
>       return filePath;
> }

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to