Re: NSThread question
Re: NSThread question
- Subject: Re: NSThread question
- From: Aurélien <email@hidden>
- Date: Tue, 10 Jul 2001 13:44:21 +0200
I still have an error (signal 10 (SIGBUS)). I'll explain exactly what I
do:
I have a -(void)doImage; method in a custom NSView object. This is the
method I'm calling in the new Thread, and it goes like this:
-(void)doImage
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc ] init];
[ self display ];
}
the method in which I call it goes like this:
-(void) setData:(NSData *) data
{
myData = [[NSData alloc] initWith
Data:data];
cachedImage = nil;
[NSThread detachNewThreadSelector:@selector(doImage) toTarget:self
withObject:nil];
}
Still obscure to me what causes the crash...
Le mardi 10 juillet 2001, ` 11:59, Stefan Jung a icrit :
>
Am Dienstag, 10. Juli 2001 um 10:47 schrieb Candide Kemmler:
>
>
> Hi,
>
>
>
> I have a button (several of them actually) which triggers a long
>
> rendering. My application not being multithreaded, the button stays
>
> blue for a long while, until the rendering's finished. I tried to do:
>
>
>
> [ NSThread detachNewThreadSelector:@selector(display) toTarget:self
>
> withObject:nil ];
>
>
>
> But then I get
>
>
>
> Jul 10 10:46:50 TT[979] *** _NSAutoreleaseNoPool(): Object 0x145d390
>
> of class NSBezierPath autoreleased with no pool in place - just leaking
>
> Jul 10 10:46:50 TT[979] *** _NSAutoreleaseNoPool(): Object 0x145d3f0
>
> of class NSBezierPath autoreleased with no pool in place - just leaking
>
> Jul 10 10:46:50 TT[979] *** _NSAutoreleaseNoPool(): Object 0x145d300
>
> of class NSCalibratedRGBColor autoreleased with no pool in place -
>
> just leaking
>
>
>
> What's wrong with my call ?
>
Your call is Ok, but you have to set up your own NSAutoreleasePool. For
>
your primary thread this is done by your application object, for
>
Threads you have to do it on your own.
>
>
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
>
The *pool destroys itself at the next opportunity, but releases all
>
autoreleased objects before. so there is no [pool release].
>
>
Stefan