Re: Opening a NSOpenPanel in a secondary thread -> crash
Re: Opening a NSOpenPanel in a secondary thread -> crash
- Subject: Re: Opening a NSOpenPanel in a secondary thread -> crash
- From: "Louis C. Sacha" <email@hidden>
- Date: Tue, 18 Nov 2003 17:16:55 -0800
Hello...
Just checking, but do you release the NSAutoreleasePool at the end of
that method?
- (void) SecThread
{
NSAutoreleasePool *lp=[[NSAutoreleasePool alloc] init];
... ... ...
[lp release];
}
Also, from everything I've read, it's better if the user interface
is limited to the primary thread, and secondary threads are spun off
to accomplish specific tasks. If there is some process happening in
the main thread that you are trying not to interrupt, maybe it would
be better to have that process spun off as a seperate thread. Or, if
it doesn't interefere with what you are trying to do, start up your
new thread after you have run the open dialog in the primary thread,
passing the appropriate info to the new thread.
Another thing, you could also try creating your own instance of
NSOpenPanel using the
- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned
int)styleMask backing:(NSBackingStoreType)backingType
defer:(BOOL)flag;
initializer it inherits from NSWindow, instead of using the
shared/recycled instance (although I haven't done this, so I don't
know if it will work properly, but it should).
Louis
I just discovered that using for several times (4-5 times) an
NSOpenPanel from a secondary thread leads to a crash.
Example: if i detach the following thread from the main thread (i'm
using NSThreads, not pthreads),
- (void) SecThread
{
NSAutoreleasePool *lp=[[NSAutoreleasePool alloc] init];
NSOpenPanel *op=[NSOpenPanel openPanel];
while(TRUE)
{
[op runModalForTypes:nil];
}
.....
}
After 4-5 cycles,the main thread crashes with this kind of stack:
#0 0x90190d5c in CFRelease
#1 0x92f299d0 in toolTipTimerFired
#2 0x92f299d0 in toolTipTimerFired
#3 0x90194848 in __CFRunLoopDoTimer
#4 0x90191ba8 in __CFRunLoopRun
#5 0x901960bc in CFRunLoopRunSpecific
#6 0x927d5ecc in RunCurrentEventLoopInMode
#7 0x927dc640 in ReceiveNextEventCommon
#8 0x927fe6d0 in BlockUntilNextEventMatchingListInMode
#9 0x92dd2a80 in _DPSNextEvent
#10 0x92de93fc in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]
#11 0x92dfd730 in -[NSApplication run]
#12 0x92eb9a1c in NSApplicationMain
Anyone has any idea of how to overcome the problem?
Is this a situation of thread unsafe AppKit?
Do i have to use distributed objects for this task?
I'm using 10.3.1 and xcode 1.0.1.
Thank you a lot.
Andrea
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.