Re: [SOLVED!] Progress Sheet on a NSDocument
Re: [SOLVED!] Progress Sheet on a NSDocument
- Subject: Re: [SOLVED!] Progress Sheet on a NSDocument
- From: glenn andreas <email@hidden>
- Date: Sun, 25 Mar 2007 12:03:50 -0500
On Mar 25, 2007, at 11:30 AM, Alan Smith wrote:
No, I didn't start it from a thread other than the main one
Yes you did.
- (void)threadedSaveMovieToPath:(NSString*)path
{
[NSThread detachNewThreadSelector: @selector(saveMovieToPath:)
toTarget: self withObject: path];
}
This tells saveMovieToPath to be performed on a new thread (which
will not be the main thread)
- (void)saveMovieToPath:(NSString*)path
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
stopProcess = NO;
[progressPanel beginModalForWindow: [self windowForSheet]
modalDelegate: self didEndSelector: @selector(sheetDidEnd: returnCode:
contextInfo:) contextInfo: nil];
And so when it gets here, beginModalForWindow is being called from a
secondary thread.
You just plain can't do UI from any thread other than the main one.
If your saving code takes a long time, you should perform all the UI
in the main thread (so your savePanelDidEnd routine shouldn't be
calling a routine to spawn a new thread), and then in the
sheetDidEnd... routine, _there_ is where you spawn off a thread with
the appropriate parameters.
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium2 | build, mutate, evolve, animate | images, textures,
fractals, art
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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